Jump to content

Learning Projects for PHP Functions?


Go to solution Solved by gizmola,

Recommended Posts

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/

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.

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 by chrisburton
  • Solution

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.