Snap40 Posted June 12, 2009 Share Posted June 12, 2009 First off Hi to all of you;) I have started taking various tutorials around the web.I am Starting to understand "in general" a few things.But just having something echo back to me what i wrote on the code seems to still not help me understand how it works on an actual site(i hope this makes sense to someone). Since allot of you are experienced coders i thought i would ask here,what would you consider to be the best way (or place) to learn php and mysql?IE:books or video tutorials or tutorials like the ones on this site.Or even an online university? Thanks in advance Snap40 Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 12, 2009 Share Posted June 12, 2009 Tutorials are intended to teach one aspect of something. You would need to find a comprehensive list of tutorials to even come close to being exposed to the amount of information and with the organization that would exist in a basic book on the subject. For example, the w3schools.com PHP tutorial briefly covers the basics, and even has a short example or two in each section, but a basic book will typically build up examples that actually do something more than echo that something worked. I recommend visiting your local book store, browsing through the books that cover the subject you are interested in, picking one that matches your level of understanding, and reading through it (multiple times as necessary.) Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-854596 Share on other sites More sharing options...
Anti-Moronic Posted June 12, 2009 Share Posted June 12, 2009 All of them. Seriously, just assault your senses and emerge yourself within the language. You will LOVE php, though it will be a love-hate relationship at first. When you finally start seeing the big picture, it's incredible. This is no doubt true for other powerful programming languages, but I started on html and css so this was a BIG evoluionary step in my programming career. The power is...wow.. Anyway, I suggest you absolutely download and install wamp as soon as you can so you can test php code locally. Get notepad++ for coding, maybe move onto something more elaborate later (I never did). Then read, watch and observe *while* you have your local server in front of you. Practice, practice, practice, it's the best way. Once you develop a firm understanding for the syntax, look up best practices and shorthand, then move onto security. Don't worry about making everything perfect, just develop your current scripts as you go. Learn to build functions and simple classes and finally move onto oop-based techniques. My best advice though is to get wamp (if you have windows) and start practicing on your machine while you read from books and/or watch vids. When you think you're ready, delve into a small! php project, like on rentacoder and see where it takes you. I learned most of what I know through *necessity* by accepting things I could only just grasp and learning as I went along. Really hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-854598 Share on other sites More sharing options...
Daniel0 Posted June 12, 2009 Share Posted June 12, 2009 Start with the manual. Make sure you've understand the syntax and make sure you know the features PHP has. Make sure you're at least decent with math (not just 1+1=2 shit, I mean real math). That will help you a lot, and the way you need to think when doing math coincides with the way you need to think when programming. A good exercise might be to try to implement some of the functions provided in PHP's library. Try for instance to implement explode without using any PHP built-in function. What does it mean to split a string into an array at a particular delimiter? Can you explain it in English (or whatever natural language you're most proficient in)? How about strlen? What does it mean to get the length of a string? Can you explain how you would do that outside the context of programming? If you can explain it using words, you can explain it to the computer with a programming language assuming you know the syntax. Programming is essentially problem solving, i.e. how do you most efficiently get a computer to perform a particular task. The kind of programming I described is called imperative programming. It works sort of like a recipe for when you're cooking. You are explaining the computer what to do with a particular input and then produce a particular type of output. Another programming paradigm is called functional programming, which I would encourage you to look into some time. With imperative programming you explain what to do, but with functional programming you explain what things are. When you are able to do problem solving and decompose a large problem into smaller subsets of problems you will want to learn how to organize your code in a practical manner. You will want to look into object oriented programming (OOP) and object oriented design (OOD). You will want to look into methodological topics such as what e.g. agile programming is, what TDD (test driven development) and unit testing is. You would probably be inclined to read tutorials like "how to create a membership system", "how to write a CAPTCHA" and so on. Practical tutorials that end with a very clear and quantifiable result. I would not recommend this. You don't want to know how to create a membership system. That skill in itself is entirely useless. You will want to know what a membership system consists of, and you will find that those individual steps are fairly manageable. Starting at a lower abstraction level has several benefits. It will train you to think about how the algorithms you implement work and it will train you to think like a programmer. Of course you will not want to use your own explode() implementation in a real program. Usually it's a waste of time reimplementing things. You will hear people say "don't reinvent the wheel", and that is true, mostly anyway. In any real application it's true, but it's not true in a learning environment. Using this approach it will probably take some time before you create anything meaningful, but in the long run you'll benefit from it. I've been know to say that "PHP is too easy", and I believe this to be true. It's too easy for anyone to start right off the bat and create something concrete. The problem is just that these people's codes are fundamentally flawed. They use bad practice, their code is highly inefficient, not at all maintainable and full of bugs and security vulnerabilities. Sure, they produced something, but the fact remains that it plain simply sucks. Programming done right is not easy, and anyone who tells you it is is either lying or not a good programmer. Don't ever think you're good enough. Don't stop at a plateau. Make sure you keep learning, keep reading, keep practicing. There is someone better than you. Strive to be better than them, strive to be the best. Remember that finishing something faster does not necessarily mean it's better. Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-854605 Share on other sites More sharing options...
Snap40 Posted June 12, 2009 Author Share Posted June 12, 2009 hi thanks for the quick answers.I have xampp on and working and have been using it for the tutorials,i have like 4 different test folders in it . A book is maybe a good idea although i like the hands on stuff better and i guess im a bit impatient as well hehe. I have also paid for a couple tutorial videos as well and enjoyed them and learned as well.I'm not sure maybe trying to create my own project and learning from my mistakes could be a route to try too. PS:thanks Daniel i was in the middle of writing this when you posted.Some good ideas i will try thanks! Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-854606 Share on other sites More sharing options...
PFMaBiSmAd Posted June 12, 2009 Share Posted June 12, 2009 Impatient and programming don't go together. Getting computers to do what you want is very detail orientated and requires an amount of reading to figure out how use the pieces present in any programming language to get from point-A (a statement of your problem) to point-B (a working solution) without wasting a lot of time and effort trying to get there. Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-854619 Share on other sites More sharing options...
Axeia Posted June 13, 2009 Share Posted June 13, 2009 Just try to create something useful for yourself if you think you got a good grasp on the basics. Try extracting the artists names from your music collection, or mimic your filebrowsers behaviour, create some script able to do some tedious task like filtering down the RSS feed of your favorite site down to only the results you find interesting. I've never really lacked a 'target objective' of something I wanted to code. Granted I use PHP for some silly things like moving files or slicing up images where I really should instead be using shell scripting or a desktop based programming language for.. but little projects tend to be a very useful learning experience. It's easier to concentrate on something when you got a purpose for it as well. Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-854822 Share on other sites More sharing options...
dreamwest Posted June 13, 2009 Share Posted June 13, 2009 Grab an example, play around with it and experiment I remember the first time i learnt how to update a database, i was jumping around. Databases used to scare me - until i found out how simple it really is. Finally : Program from the heart - its more fun Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-854911 Share on other sites More sharing options...
Daniel0 Posted June 13, 2009 Share Posted June 13, 2009 Grab an example, play around with it and experiment Unless you somehow can ascertain the quality of that example, I would be extremely cautious with that approach. Worst case you end up picking up a lot of bad habits and bad practices. See the PHP Help forum for proof. Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-854914 Share on other sites More sharing options...
dreamwest Posted June 13, 2009 Share Posted June 13, 2009 Grab an example, play around with it and experiment Unless you somehow can ascertain the quality of that example, I would be extremely cautious with that approach. Worst case you end up picking up a lot of bad habits and bad practices. See the PHP Help forum for proof. I love php and mysql manuals now, but i couldn't understand them when i started. Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-854922 Share on other sites More sharing options...
waynew Posted June 13, 2009 Share Posted June 13, 2009 Pick a simple project such as a blog with a login system to start off with. Learn enough PHP & MySQL to build it. Then post your code here and let others tell you what you could have done better. Go back and make it better. Then post again. Then start a new project. The #1 thing is to keep looking for ways to improve your code. There's nothing better than figuring out how to do something in three lines of code, where it used to take you fifty! Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-854935 Share on other sites More sharing options...
Snap40 Posted June 13, 2009 Author Share Posted June 13, 2009 hi thanks everyone now i will find a suitable project to try on my own,that should keep me busy for the next month or so lol Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-854985 Share on other sites More sharing options...
roopurt18 Posted June 13, 2009 Share Posted June 13, 2009 Ditto to what waynewex said. I've been programming for close to 15 years now and I think I can accurately outline the learning hurdles you need to overcome: When initially learning you are presented with programming concepts in general and a specific programming language. Programming concepts are things like functions, arguments, return values, pass by value, pass by reference, memory management, references, pointers (maybe not so much any more), algorithms, and then finally more advanced topics like object oriented programming, abstract data types, advanced algorithms, etc. It will take some time before you can effectively use these concepts to solve a particular problem; you actually have to train your brain to think a little differently about things. A specific programming language is all about how it implements those general concepts. An example would be all PHP programs start with <?php or PHP functions begin with function theName() { or that PHP uses references rather than pointers. Really it's about the syntax, which is what you have to type, where you have to type it, and what it has to look like. The beautiful thing about programming is the general concepts do not change from language to language, only the syntax. A real programmer can easily learn new languages and write the same programs in many languages because all that changes from language to language is syntax (and a few other silly things sometimes). I've known a few people that could program one language but were unable (or maybe just unwilling) to learn a new language, saying it was "too difficult" to get around the different syntax. IMO they're not really programmers. As a beginner the general concepts you need to be familiar with are: variables, functions, loops, conditional statements, input and output. Once you know how those all work in PHP, start writing small programs. After it's finished, think about how you could have written it differently. Ask yourself, "What design decisions did I make in this program that made programming it harder than it needed to be?" Ask yourself if the program is easy to maintain. Do you think you could open the file in 6 months and follow your own code? Then actually open the file 6 months later and look at your old program and critique it then. As I said I've been doing this for a while. Once you overcome the hurdle of learning about general concepts, the rest is just how a specific language accomplishes a specific task. The only real way to get better is to write lots of programs and constantly try to make them better! Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-855064 Share on other sites More sharing options...
Daniel0 Posted June 13, 2009 Share Posted June 13, 2009 The beautiful thing about programming is the general concepts do not change from language to language, only the syntax. I'd argue that programming in Haskell or Lisp is fundamentally different from programming in PHP or C. Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-855164 Share on other sites More sharing options...
roopurt18 Posted June 14, 2009 Share Posted June 14, 2009 And you'd be right. I guess I could have been more clear and said within a particular type or class of programming language, the general concepts don't change. Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-855437 Share on other sites More sharing options...
pneudralics Posted June 14, 2009 Share Posted June 14, 2009 Best way to learn is to just do it! The more you play with it the more you'll learn. I think I'm still a newbie but when I'm finished with a project I look back and sometimes wonder how the heck I did it. Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-855444 Share on other sites More sharing options...
Daniel0 Posted June 14, 2009 Share Posted June 14, 2009 Best way to learn is to just do it! The more you play with it the more you'll learn. I think I'm still a newbie but when I'm finished with a project I look back and sometimes wonder how the heck I did it. I guarantee you, in half a year you'll think what you did sucks. If you don't something is wrong and you haven't learned anything in the mean time. Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-855484 Share on other sites More sharing options...
pneudralics Posted June 14, 2009 Share Posted June 14, 2009 Best way to learn is to just do it! The more you play with it the more you'll learn. I think I'm still a newbie but when I'm finished with a project I look back and sometimes wonder how the heck I did it. I guarantee you, in half a year you'll think what you did sucks. If you don't something is wrong and you haven't learned anything in the mean time. I'm pretty sure in a half of year I'll probably think what I did sucks. I'm still learning. When I look at my codes I know what I did. I meant to say something more along the lines of I'm amazed I've come this far from just reading books and getting help here. Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-855643 Share on other sites More sharing options...
jxrd Posted June 14, 2009 Share Posted June 14, 2009 Lol, Daniel0; your post about doing stuff just for the sake of it got me thinking...so I had a go at making an explode function like you suggested. <?php class explode { var $string, $buffer = array(); function __construct() { return true; } function explode($delimiter, $string) { $this->string = $string; $string = array(); foreach($this->tokenise() as $key => $value) { if($value == $delimiter) { array_push($string, implode($this->buffer)); $this->buffer = array(); } else { array_push($this->buffer, $value); } } return array_merge($string, array(implode($this->buffer))); } function tokenise() { $array = array(); for($i = 0; $i < strlen($this->string); $i++) { array_push($array, substr($this->string, $i, 1)); } return $array; } } $explode = new explode; $string = 'hello world '; print_r($explode->explode(' ', $string)); ?> Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-855652 Share on other sites More sharing options...
corbin Posted June 14, 2009 Share Posted June 14, 2009 Best way to learn is to just do it! The more you play with it the more you'll learn. I think I'm still a newbie but when I'm finished with a project I look back and sometimes wonder how the heck I did it. I guarantee you, in half a year you'll think what you did sucks. If you don't something is wrong and you haven't learned anything in the mean time. I'm pretty sure in a half of year I'll probably think what I did sucks. I'm still learning. When I look at my codes I know what I did. I meant to say something more along the lines of I'm amazed I've come this far from just reading books and getting help here. I've been coding PHP for I think around 3 years now, and I still look back at things sometimes and I'm like "Wtf?!" jxrd, I have a question... Why did you wrap it in a class? I'm procrastinating what I should be doing (x.x), so I decided to give it a go: //array explode ( string $delimiter , string $string [, int $limit ] ) //I don't feel like implementing $limit //Also, I would use better names than $d and $s if I were going to use this for real lol. function splode($d, $s) { $len = strlen($s); $offset = 0; $out = array(); //while(($place = strpos($s, $d, $offset)) !== false) { while($offset < $len && ($place = strpos($s, $d, $offset)) !== false) { $out[] = substr($s, $offset, $place-$offset); $offset = $place+1; } //The place = blah !== false will not get the last match... if($offset < $len) { $out[] = substr($s, $offset, $len-$offset); } return $out; } print_r(explode(' ', 'This is a string with spaces!')); print_r(splode(' ', 'This is a string with spaces!')); When ever I first got into C++, I didn't know that the std::string class had a method designed for tokenizing a string, so I once recreating explode() in C++. It was essentially the same as this haha. Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-855710 Share on other sites More sharing options...
jxrd Posted June 14, 2009 Share Posted June 14, 2009 jxrd, I have a question... Why did you wrap it in a class? Idk, I needed to use two functions...thought it would be appropriate. I guess I'm just not as resourceful as you But...I bet you can't do strlen() !!!!! <?php function str_len($str) { $str = preg_split('/./', $str); return count($str) - 1; } echo str_len('7 chars'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-855719 Share on other sites More sharing options...
Daniel0 Posted June 14, 2009 Share Posted June 14, 2009 Heh... you cheated and used built-in functions. Here you go with a with an explode() implementation that doesn't use any of PHP's built-in functions whatsoever. function myStrlen($string) { for ($length = 0; isset($string[$length]); $length++) {} return $length; } function myExplode($delimiter, $string, $limit = null) { $parts = array(); for ($i = 0, $j = 0, $length = myStrlen($string); $i < $length; $i++) { if ($string[$i] == $delimiter && ($limit === null || $limit > $j+1)) { $j++; continue; } if (!isset($parts[$j])) { $parts[$j] = $string[$i]; } else { $parts[$j] .= $string[$i]; } } return $parts; } Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-855720 Share on other sites More sharing options...
jxrd Posted June 14, 2009 Share Posted June 14, 2009 Oh, well, you didn't say we couldn't use built in functions... Btw you used isset()!! Although, is that a language construct or a function..? Suggest another; this is fun Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-855723 Share on other sites More sharing options...
Daniel0 Posted June 14, 2009 Share Posted June 14, 2009 isset() is a language construct, so I still win Here you have a few others: function myImplode($glue, array $pieces) { $string = ''; $maxIndex = myStrlen($pieces)-1; // myStrlen() will work for arrays because of the way it's written foreach ($pieces as $i => $piece) { $string .= $piece; if ($i != $maxIndex) { $string .= $glue; } } return $string; } function myStrpos($haystack, $needle, $offset = 0) { for ($i = $offset, $length = myStrlen($haystack); $i < $length; $i++) { if ($haystack[$i] == $needle) { return $i; } } return false; } function myStrrpos($haystack, $needle, $offset = 0) { for ($i = myStrlen($haystack) - 1 - $offset; $i >= 0; $i--) { if ($haystack[$i] == $needle) { return $i; } } return false; } Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-855726 Share on other sites More sharing options...
jxrd Posted June 14, 2009 Share Posted June 14, 2009 Lol How would you do foreach()? I tried it in C++ the other day...didn't do too well. C++ arrays confuse me...with their vectors and stuff. My initial thoughts would be var_export()...but obviously that's a built in function. Appologies for off-topic-ness btw Quote Link to comment https://forums.phpfreaks.com/topic/161965-best-way-to-learn-phpmysql/#findComment-855728 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.