Web Design Forum: TUTORIAL: PHP Functions - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

TUTORIAL: PHP Functions Rate Topic: -----

#1 User is offline   webdesigner93 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,976
  • Joined: 22-September 09
  • Reputation: 222
  • Gender:Male
  • Experience:Web Guru
  • Area of Expertise:Web Developer

Posted 18 November 2009 - 11:09 PM

Ok imma start out by explaining what a php function is a function in php basicly can be used to hold blocks of code that you wanna use more then one time in your scripts. To start a function you write out the word
function
like so then you give the function a name

function mycat()

{
//Block of code goes here
}


So say you wanted to have a function that protects variables when inserted in a database you could do this

function protect($value){
$value = mysql_real_escape_string($value);

return $value;

}


So this code creates a function that uses mysql_real_escape_string to protect any variable you might like if your inserting it into a database to use this function just call it like this.


$myvariable = protect($_POST['name']);



So as you can see we wrapped our function around $_POST['name'] this will protect whatever value name is when inserted into a mysql database.

To simply output something that is inside a function you would do this


function hello(){
echo "HELLO WORLD!";

}


Then call this function like this



hello();


And that when ran will print out HELLO WORLD!

so this was a short tutorial on functions and how to
use them in php if you
like this tutorial give me a +1 thanks
2

#2 User is offline   weblearner 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 27-February 10
  • Reputation: 0

Posted 27 February 2010 - 11:49 PM

You can find a good tutorial at http://www.w3shools.com/



_______________________________
webmaster newbie: iboro(dot)tk
0

#3 User is offline   Zahid Habib 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 15
  • Joined: 06-March 10
  • Reputation: 0

Posted 07 March 2010 - 04:22 AM

Nice tutorial.Thanks
0

#4 User is offline   Anshuman 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 23
  • Joined: 23-December 10
  • Reputation: 0
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:SEO

Posted 23 December 2010 - 11:10 AM

Not only php functions,also array functions, also sql queries you can find here http://php.net/manual/en/index.php>
Just go to the link and download it and then you can type any functions in php you can find here.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users