View Full Version : about php

11-29-2007, 05:44 AM
hi guys ..
can anyone here tell me about php.......i want to know that How to write user defined function in PHP.....how calling that function in PHP.....return value in PHP ...How end function? in PHP Arrays start with 0 or 1? in PHP.....if syntax? in PHP......:):)

11-29-2007, 06:30 AM

lets start with the function aspect

to writ a function you declare it as a function and name it. It has brackets and braces

function myfunction(){}

lets look at the structure

function myfunction($arg1,$arg2,$arg3){

//do stuf here using the $arg's;

return $result;


you call a function simply by using the following...

myfunction('1', '2', '3');

as you can see the call can contain arguments which are passed into the function for processing. You can pass any data type in as an argument like dates or strings or alpha numerics. You can pass in variables also

if you pass in an argument you must provide a variable or variables in the function to catch the value in the brackets. If you dont you will get an error.

inside the function you can write what ever you like to process data or handle arguments

if you want to spit some processed data out after the function has run then you return it... see above

if you are using data which has been through a function you can call and use a function like this...

/////// With true or false being expected output. (An IF statement) ////////
if(myfunction('1', '2', '3') == true){

// do stuff here


/////// With numeric being expected output. (An IF statement )////////
if(myfunction('1', '2', '3') == 10){

// do stuff here


/////// With alpha numeric string being returned for display using a simple echo. ////////
echo myfunction('1', '2', '3');

// do stuff here

please start a new post for other questions like arrays

11-29-2007, 06:47 AM
thanks a lot for the quick reply......:-D
can you tell something more .....i mean i want to clear one more point here....that is how can i implement an array php function to a mysql database .....the syntax in making a PHP array connecting to mysql database. I mean using the PHP array functions..... it will automatically save the data (array) to the mysql database........

thanks for your time...

11-29-2007, 07:27 AM
ok post your insert statement and we will look at converting it into a function

how is your coding skills