chrisburton Posted September 12, 2014 Share Posted September 12, 2014 Hi, everyone. I'm having some trouble finding tutorial projects for PHP Functions. Can anyone point me in the right direction if you know of any? I apologize if this is the wrong category to post in for my particular question. Quote Link to comment Share on other sites More sharing options...
gizmola Posted September 12, 2014 Share Posted September 12, 2014 Are you trying to understand functions in general, or looking for more of a cookbook for use of existing php functions? Quote Link to comment Share on other sites More sharing options...
chrisburton Posted September 12, 2014 Author Share Posted September 12, 2014 Are you trying to understand functions in general Yes! Sorry I didn't clarify that in the beginning. I am trying to learn the syntax by doing little projects and what not. Quote Link to comment Share on other sites More sharing options...
gizmola Posted September 12, 2014 Share Posted September 12, 2014 Chris, I'm still not clear. A: Are you trying to understand functions in general B: Looking to gain cookbook knowledge of existing php functions? Quote Link to comment Share on other sites More sharing options...
chrisburton Posted September 12, 2014 Author Share Posted September 12, 2014 Answer = A I am trying to understand functions in general. Again, sorry! Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted September 12, 2014 Share Posted September 12, 2014 If you're looking to build your own functions, the PHP manual has section on that topic here: http://php.net/manual/en/language.functions.php To learn about existing PHP functions, you could search for them in the manual. http://php.net/ Quote Link to comment Share on other sites More sharing options...
gizmola Posted September 12, 2014 Share Posted September 12, 2014 This article does a pretty good job. Don't worry about the message at the top -- the basics of writing functions in php hasn't changed. http://www.brandonsavage.net/how-to-write-a-function-in-php/ Quote Link to comment Share on other sites More sharing options...
chrisburton Posted September 12, 2014 Author Share Posted September 12, 2014 I saw the manual but I was looking for little projects I could do to help me learn a little better. Sort of a 'learn-by-doing' kind of thing. Something like this: https://github.com/karan/Projects but more dedicated to PHP functions and/or classes. A beginners guide. Quote Link to comment Share on other sites More sharing options...
chrisburton Posted September 12, 2014 Author Share Posted September 12, 2014 (edited) This article does a pretty good job. Don't worry about the message at the top -- the basics of writing functions in php hasn't changed. http://www.brandonsavage.net/how-to-write-a-function-in-php/ Isn't that tutorial a bit out of date? Also, some of the code seems bad practice (i.e. using == rather than ===). Edit: Ah. You WERE talking about the Out of Date warning, not the 30 day trial. Edited September 12, 2014 by chrisburton Quote Link to comment Share on other sites More sharing options...
Solution gizmola Posted September 12, 2014 Solution Share Posted September 12, 2014 As I said, the information is still good. Whether or not you use '==' or '===' is situational. It's not like '==' is deprecated. The important thing is to understand is when using '===' will evaluate as FALSE. I don't use '===' unless I absolutely require it, because the nature of PHP is to be loosely typed and to intrinsically typecast variables in the way you typically want them to be typecast. As for a project -- I find that the best one will be the one you come up with, where you attempt to build something that interests you. Many years ago, I had a webcam sitting in the window of my house, so I wrote some scripts that did things like assemble up groups of stills it took into mosaics. Whatever area interests you, is going to be the one that leads you into a DIY project where you can apply what you've learned, and invariably it will teach you much more than something canned, because you will have to problem solve, which is what real programming is actually about. You can mix and match functions and objects in projects however you like. Once you are clear on the underlying concepts, you should be able to figure out how to create a function library to support that project. At its simplest, concentrate on making simple discreet functions that do one thing. Try and organize said functions into one or more php scripts that you will include in your main script. So you don't get bogged down, just put them in a /include directory off your webroot/project directory and call it "functions.php" until such time as you have enough of them to warrant regrouping them. Quote Link to comment Share on other sites More sharing options...
chrisburton Posted September 12, 2014 Author Share Posted September 12, 2014 Thanks a lot for the help and clarification. I really appreciate it. Quote Link to comment 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.