PHP Classes - Week 4 : Functions (Part 1)  

Posted by John Clarke, Business Partner, jc-Interactive

Today we are covering functions. All languages have them, and they are used differently in each. The basics for a PHP functions looks as follows:

  
Pretty basic as you can see :) You have the keyword function in front of the name that you wish to assign to the function. Just note that this is the basics, this is not how it looks in the end ;) Moving on, lets do something interesting to it, just for the tutorial purposes :)
 "; 	} 	 	$my_people_array = array( "Piet", "Koos", "Sannie" ); 	 	foreach( $my_people_array as $person_name ) 	{ 		printMeSomething( $person_name ); 	} ?> 
As you can see from this code, I create a array and fill it with some names. Afterwards if loop through these using the foreach loop and call the printMeSomething function. The function then in turn takes the name as variable $my_incoming_variable and concats and echo's out for e.g. "Piet has been pondering about life" Pretty basic still, so shall we step it up a notch?
 [...] 

Later! John Clarke :)

This entry was posted on Saturday, March 6, 2010 at 12:40 AM . You can follow any responses to this entry through the comments feed .

0 comments

Post a Comment