Docsity
Docsity

Prepare-se para as provas
Prepare-se para as provas

Estude fácil! Tem muito documento disponível na Docsity


Ganhe pontos para baixar
Ganhe pontos para baixar

Ganhe pontos ajudando outros esrudantes ou compre um plano Premium


Guias e Dicas
Guias e Dicas


Use a Cabeça! - PHP com MySQL, Notas de estudo de Cultura

Um bom livro para quem pretende adiquirir conhecinheto na linguagem php usando o banco de dados mysql

Tipologia: Notas de estudo

2011
Em oferta
30 Pontos
Discount

Oferta por tempo limitado


Compartilhado em 16/11/2011

pedro-amaral-13
pedro-amaral-13 🇧🇷

4.7

(3)

1 documento

1 / 762

Toggle sidebar

Esta página não é visível na pré-visualização

Não perca as partes importantes!

bg1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64
Discount

Em oferta

Pré-visualização parcial do texto

Baixe Use a Cabeça! - PHP com MySQL e outras Notas de estudo em PDF para Cultura, somente na Docsity!

Head First PHP & MySQL Es FF Load all the key 2EA syntax directly into your brain Discover the secrets behind dynamic, database-driven sites Avoid embarrassing Hook up your mishaps with á PHP and web forms e MySQL code ei - TM, 7 DR Flex your scripting knowledge with dozens of exerciges O REILLY* Lynn Beighley & Michael Morrison Head First PHP & MySQL Web Programming: PHE What will you learn from this book? Ready to take your static HTML web pages to the next level, and viven sites using PHP and MySQL: Then Hed Fira PHP & MySQL is your hands-on guide to g Get your hands dirty building real applicarior ing From a video game high-score mess: baile database ng dynamic sites running, | ze board to am online s anel cookies, per rming database queries amd joins, handl file 140 operations, amd more. Create à ha store Lara for pour Eauotibe rot É voll E Pl video game Syndicate e jose site rh he Feeds Add log-im Funttionaity to jour ube with toolies and sessions - Develop the perfect L database sthena, way does this book look so different? We think your time às too valuable to spe md serugeling with mew comcepas. DU he latest res E ence and learning theory to craft a mult e Head First PHP & MySQL uses a vor brain wor sm ming exp ch formar des sually gned for the vy approach that puts you to sleep. E mota text-he: 15 44,08 CAN g44,08 T5EN: PT8-0-5948-00830-3 um iih Safari? 2:22 O REL der 45 dasys wmdh ; pairclvaõe of thig book wrvrveoreillycom Details on last page. wrveheadhrstlabs.com 780596 web applications and are always Bor my parents, who frequently there for me. - Lynn Beighley To Rasmus Lerdord who smgle-handedly sparked the language that would eventually become PHP itnom: Endurimg proof that it really only takes one person to lead us all down a new, more enlightened path. - Michael Morrison we know the author(s) Author(s) of Head First PHP & MySQL Lynn Beighley is a fiction writer stuck in a technical book writer's body. Upon discovering that technical book writing actually paid real money, she learned to accept and enjoy àt. After going back to school to get a Masters in Computer Science, she worked [or the acronyms NRL and LANL. Then she discovered Flash, and wrote her first bestseller, A victim of bad timing, she moved to Silicon Valley just before the great crash. She spent several years working for Yahoo! and writing other books and training courses. Finally giving in to her creative writing bent, she moved to the New York area to getan MEA in Creative Writing, Her Head First-style thesis was delivered to a packed Michael Morrison has been an enthusiastic contributor to the online world ever since he ran a BBS on his Commodore 64 way back when being a nerd was far less cool than it is these days. A few thousand baud later, he still marvels at how far we've come, and how fast. Michael doesn't run a BBS anymore, but he's suill very much involved in the modern equivalents and the tools we use to build them. He spends most of his “official” time writing about web-related technologies, having authared or co-authored over fifly books ranging from mobile game programming to XML. He entered the Head First foray with Head First JavaScript, and hasn't room of professors and fellow students. It was extremely looked back. well received, and she finished her degree, finished , , . . Head Fist SQL, anel just finished Head First PHP & Michael is also the founder of Stalefish Labs (www MbSQL Whew! stalefishlabs. com), an entertainment company specializing in games, toys, and interactive media, And he's been known to actually spend time offline (gasp!) skateboarding, playing ice hockey, and hanging out next to his koi pond with his wife, Masheed. He even slecps every once ir a while. Lynn loves traveling, writing, and making up elaborate background stories about complete strangers. She's a little seared of UFOs. viii how to use this book Who is this book for? Le you can answer “yes” to allof these: O) Are you a web designer with HTML or XHTML experience and a desire to take your web pages to the next level? (2) Do you want to go beyond simple HTML pages to learn, understand, and remember how to use PHP and MySQL to build web applications? Do you prefer stimulating dinner party conversation to dry, dull, academic lectures? this book is for vou. Who should probably back away from this book? If you can answer “ves” to any of these: O) Are you completely unfamiliar with basic programming concepts like variables and loops? (But even if you've never programmed before, you'll probably be able to get the key concepts you need from this book.) O) Are you a kick-butt PHP web developer looking for a reference book? 6) Are you afraid to try something different? Would you rather have a root canal than mix stripes with plaid? Do you believe that a technical book can't be serious if it creates an alien abduction database? a ta this book is not for vou. ENote From marketing: this book is for anyone vith a tredit card] xxvili intro the iniro We know what you're thinking “How can this be a serious PHP and MySQL book?” “What's with all the graphics?” “Can T actually learn it this way?” We know what your brain is thinking ( ii Your brain craves novelty, TÚs always searching, scanning, waiting for something unusual. twas built that way, and it helps you stay alive. So what does your braim do with all the routine, ordinary, normal things you encounter? Everything it can to stop them from interfering with the brain's real job-—recording things that metter. It doesn't bother saving the boring things; they never make it past the “this is obviously not important” filter. How does your brain know what's important? Suppose youre out for a day hike and a tiger jumps in front of you, what happens inside your head and body? Neurons fire. Emotions crank up. Chemicals surge. And thaús how your bram knows... Great. Only 750 more dull, dry, This must be important! Don't forget it! But imagme you're at home, or tm a library. TV's a safe, warm, tiger-free zone. boring pages. You're studying. Getting ready for an exam. Or trying to learn some tough + loedim ks o technical topic your boss thinks will take a week, ten days at the most. Tui Rd o Just one problem. Your brain's trying to do you a big favor. IU's trying to make sure that this obzimes!y non-important content doesn't clutter up scarce resources. Resources that are better spent storing the really big things. Like tigers. Like the danger of fire. Like how to quickly hide the browser window with the YouTube video of space alien footage when your boss shows up. sam N And there's no simple way to tell your bram, “Hey bra, thank you very much, but no matter how dull this book is, and how little Pm registering on the emotional Richter scale right now, [really do want you to keep this stufl around.” UFO footage on YouTube is obviaushy more interesting to your brain than some tomputer book ia you are here + xxix the intro Metacognition: thinking about thinking [you really want to learn, and you want to learn more quickly and more I wonder how I can trick my brain into remembering this stuff... deeply. pay attention to how you pay attention. Think about how you think Learn how you learn. Most ol us did not take courses on metacogniton or learning Ueory when we growing up. We were expected to learn, but rarely daught to leu W Butwe assume thatif you're holding this book, you really want to learn how to build database-driven web sites with PHP and MySQL. And vou probably dortiwant to spend a lot of time. TE vou want to use what you read im this book. you need to remember what you read. And for that, vouve got to understand 1. To gerthe most from this book, or auy book or learning experience, take responsibility for your brain. Your bram on this content. The trickas to get your bram to see the new material youre learning as As impo Really Important. Crucial to your well-bei antas a tiger. Orherwise, voure in for a constant battle with vour brain doing its best to keep the new content from sticking. So just how DO you get your brain to treat PHP & MySQL like it was a hungry tiger? There's the slow; tedious way, or the faster, more effective way. The slow way is about s] nember even the dullest of tópies if vou kecp pounding the s. + enough repetition, your brain says, us doesi't feel important to him, but he gal the same thing over and over and over, so | suppose it must be,” Neuron, schmeuron. Some of us are here rrepettion: You obviously know that you are able to Je ane re e thing Mo your brain. Y keeps le “he faster wav is to do anything that increases brain activity, especially dillerent bspes of by and they're all things that have been prover to help your brain wor votam the pict - a caption or in the body text) causes your brain to try to to rock! vactivity Phe things on the previous page are a big part of the solutim im your favor. E example, stud how that put somewhe: nthe page, h makes sense of how the words and picture relate g words s hey deseribe (as opposed to and this causes more neurons to fire More neurons firing = more chances for your brain to get tal this às something worth paying attention tos and possibly recording. A conversational style helps because people tend to pay more attention when they perceive that theyre im a conversation, smee they're expected to follow along and hold up their end. The aging ing is, your brain doesn't necessarily care that the “conversation” is between vou anda book! On the other hand, if the writing style is formal and dry, your brain perceives it the same way you experience being lectured to while sitông in 2 roomful of passive attendees. No need to stay awake, But pictures and conversatonal style are just He beginning... vou are here » xxxi how to use this book Horror mories , Here's what WE did: We used pictures, because your bram is tuned for visuals, not text, As [ar as your brain's ch! concerned, a picture really is worth a thousand words. And when textand pictures work together, we embedded the text in the pictures because your brain works more effectively when the text is coifhin the thing the text refers to, as opposed to in a caption or buried in the Horror montes hd text somewhere. We used redundancy, saying the same tung im different ways and with different media types, and multiple senses, to increase the chance that the content gets coded into more than one area of your bram. A mismat We used concepts and pictures im unexpected ways because your brain às tuned for novelty, and we used pictures and ideas with at least some emotional content, because your brain is tuned to pay attention to the biochemistry of emotions. That which causes you to feel something is more likely to be remembered, even if that feeling is nothing more than a hitle humor, surprise, or interest. le We used a personalized, conversational style, because your brain is tuned to pay more attention when it believes you're im a conversation than if it thimks you're pa y listening to a presentation. Your brain does tis even when you're reading. We included more than BO aetivities, because your brain is tuned to learn and remember more when you de things than when you read about things. And we made the exercises challenging-yet-do-able, because that's what most people prefer. th | We used multiple learning styles, because you might prefer step-by-step procedures, while / x Ty A semeone else wants to understand the big picture first, and someone else just wants to see an example. But regardless of your own learning preference, everyone benefits from seeing the same content represented in multiple ways. We include content for both sides of your brain, because the more of your bram you engage, the more likely vou are to learn and remember, and the longer you can stay focused. Since working one side of the brain often means giving the other side a chance to rest, you can be more prodnetive at learning for a longer period of time. And we included stories and exercises hat present more than one point of vie, because your brain is tuned to learn more deeply when it's forced to make evaluations and judgments. We included challenges, with exercises, and by asking questions that dot always have astraight answer, because your brain is tuned to learn and remember when it has to soork at something; Think about it-—-you can't ger your body in shape just by ratching people at the gym. But we did our best to make sure that when you're working hard, it's on the right things. That you're not spending one extra dendrite processmg a hard-to-understand example, or parsmg difcult, jargon-laden, or overly terse text. We used people. In stories, examples, pictures, etc., because, well, because jotw'v a person. And vour brain pays more attention to peaple than it does to things. xeoxxii intro how to use this book Read Me “Thais is a learning experience, nota reference book. We deliberately stripped out everything thatmight getin the way 0F learning whatever Lis we're working on at that point in the book. And the first time through, vou need to begin at the beginning, because the book makes assumptions about what you've already seen and learned. We begin by teaching simple programming concepts and database connection basics, then more complicated PHP functions and MySQL statements, and finally more complex application concepts. Wiie its important to create applications that allow users to add data to and retrieve data from your web application, before you can do that you need to understand the syntax of both PHP and MySQL. So we begin by giving vou PHP and MySQL statements thai vou cam actually try yourselÊ Phat way vou cam vediately do something with PHP and MySQL, and vou wall begin to get excited about them. "Then, a bit later m the book, we show you good application and database design practices. By then you'll have a solid grasp of the syntax von need, and can focus on learning the concepts, We don't cover every PHP and MySQL statement, function, or keyword. While we could have put every single PHP and MySQ] ent function, and keyword im this book, we thought yowd prefer to have a reasonably lifiable book that would teach vou the most important statements, functions, and keywords. We 4 need to know, te ones yo” Ih use 95 percent of the time. And when your ve you the ones you done vath this book. you'll have the confidence to go look up that function you need to finish off that You tan attually use PHP Yf with Ehis book by making à few modifitations to the We support PHP 5 and MySQL 5.0. Em tode: Chetk them out in FEI of Appendix i kick-ass spplication you justwrote, Because so many people súll use PHP + or 5, we avoid any PHP 4, 5,07 6 specihe code wherever possible. We suggest you use PHP 5 or 6 and MySQL 5 or 6 while learcing the concepts in this book. In developing this book, we focused on PHP 5 and MySQL 5, while making sure our code was compatible with later versions. You need a web server that supports PHP. PHP has to be run through a web server to work correctly You need Apache or some other web se ane or a machine to which you have some access so Uat vou can run MySQL commands on the data. Check out Appendixes ii and mm for xtend PHP and MySQL. er installed on your local ma instruchons on how to mstall and xxxiv intro the intro We use MySQL. While there's Standard SOL language, in this book we focus om the particula oÉ MySQL. With om anges, the code in this book should avork with Oracle: MS SQL Server. PostgreSQL. DB2. and quite a few more Relational Database Management Systems (RDBMSs) out there. You'll need to loole up the parúeular PHP *ctto these other RDBMSs. LÊ we covered ion in syntax for every command in the book, this book would have many more pages. We like trees, so we're focusing on MySQL. tax funchons and syntax 1É you want to co) EVENV Va The activities are NOT optional. : - part of the core content of the book. Some of them are to help with memory, some are for understanding, and some will help vou apply what vouve learned, Don't skip the exercises. The crossword puziles are the only ing vou don't have to do, but they're good É think about the words and terms you've been learning e vour bram a chance to rent context. The redundancy is intentional and important. One distner difference in a Head First book is that we wa want you to finish the book remember nt vou to realy getit, And we ge what vou've learned. Most reference books don't have retention and recall as a goal, bot this book is about learning, so yo TT sec some of the ame concepts come up more than once. The examples are as lean as possible. Our readers tellus that it ustrating to wade through 200 lines of an example looking tor the two lines they need to under É Mostexamples in this book are shown within the smallest possible context, so that the p d simple. =, Dont expeetall of the examples to be ultra robust, or abvavs complete they are written Several of the examples specifically for learning, and aren't neces y fully-funchonal. are Lull-blown web applications tha do some pretty powerful things tvou're trying to learn is clear à We've placed all of the example code and applications on the Web so you can copy and paste parts oÉ them into your text editor or MySQL Terminal, or upload them as-is to your own web server for testing. You'll find it all at http://wwwheadfirstlabs.com/books/hfphp/ The Brain Power exercises don't have answers. «he experience ol the Bram Power activities is Bor some of th ve às no night answei and for others, partof the learning for you to decide 1! and when vour answers are right. In some of the Brain Power exercises, vou will find hints to point you in the right direction. you are here + XXXV the intro Acknowledgments Ouwr editors: Many thanks go to Brett MeLaughlin for the awesome storvboarding session that got us on the right track, and his ruthless commitment to cogmtive learning, The book would not exist if not for the heroie effort, patience, and persistence of Sanders Kleinfeld. He always managed to-catch a l the balls, or was it cats, we were jugglng when we inevitably dropped Brett Mie auhlin one (or three!) and we appreciate it. We hope he gets a chance to put his feet up for a couple of days before taking on another project as difficult as this one. The O'Reilly team: Thanks to Lou Barr lor her phenomenal design skill, makimg this book such a visual treat Thanks also to Brittany Smith [or all her hard work at the last minute, and to Caitria MeCullough for getting the example web sites up and running. And to Laurie Petrycki lor having faith that we could write another great Head First book. Sanders Eleinfeld a Lou Bar And more: Finally a big thanks goes out to Elvis Wilson lor putting together the alien YouTube videos for Chapter 12. Excellent job! Especially sceing as how he's merely a simple caveman art director. you are here + xxxvii safari books online Safari Books Online Sa fa ri ** When you see a Safari icon on the cover of your favorite technology book that means the book is available onhne through the O'Reilly Nenwork Safari Bookshelf. Besks Online Safari oTers a solution that's better than e-books. It's a virtual hbrary that lets you easily search thousands of top tech books. cut and paste code samples, download chapters, and find quick answers when vou need the most accurate, current information. Try à for free athttp://safari.oreilly.com. xxxviii intro sometimes just HTML isn't enough HTML is static and boring HTMLS great for creating web pages, that much we alvcady know: But what about when you need web pages that actually do something? Suppose you need to search a database or send an email... what then? HT'ML falls short because iUs a pretty lifeless language, designed for displaying information that never changes. HTML is great if you just want to share apieteot > Emo, your pet... but not se great if You want to interalt É + These people with visitors to your site E àre looking Lor | O ii The HTML. code in these pages is determined when the web developer ercates the pages. Web server Ctabie HTML. pages ave omby ea úhen à web developer edits à dtoml file and uploads it to Lhe web server The web server .) limited to serving, wp one statie HTML page after anobher. Wah pure HTML web pages, the server Client web browser The web server's a big partof the problem with lifeless HTML since 1t serves às nothing more than à bormg delivery mechanism. E A browser requests a page, the server responds with HPML, end simply serves up of story To turn web sites into interactive web applications, static HTML that can the web server has to take on a new, more dynamie role... a role made possible by PHP. only display content. — 2 Chapter 1 u ado life to your static pages Eh a little hel Adi from the Edi PHP brings web pages to life PHP allows you to manipulate web page content om the server just before a page is delivered to the client browser. Ttworks like this: With PHP 1m the A PHP scriptruns on the server and can alter or generate HTML ; th b code atwill. An HTML web page is still delivered to he browser, mix, lhe web server which doesn't know or care that PHP is involved in tweaking the HTML on the server. is able to dy namically generate HIML web pages on the Ily. The HTML tode m these Pages is generated by PHP PHP seripts ave sto The brosser still reteives e e age gn on Lhe web server, vise regular ATL. web pages, E H pri ad e web Eus pritrsel od but the code's been pplication needs then delivered to the dynamitalhy generated by browser as HTML pages PHP on Lhe server Client web browser a PHP sexipts contain both HTML. tode and PHP stript tode that determines how the HTML. tode's manipulated Web server Dynamie HTML pages change in response to programmatie legie in PHP seripts, making them intredibly +lexible nie PHP stores and retrieves data from à database MySQL and intorporates Lhe Database data into the HTML tode that it senerabes you are here + 3