Sunday, February 27, 2011

Create-new-function-PHP (part 2)

Assalamu'alaikum and selamat sejahtera

For this post we will try some function to display the variable.Ok,here is the example:

<?PHP
$display_text = "variable Detetceted";
display_message( );
function display_message( ) {
print $display_text;
}

?>

Run it,it print error ryte?so we call it and already declared the variable "$display_text" and yet we still can not display that variable in the function.So,as the conclusion,the function must have its variable itself ,then it can display its variable.what i meant is like this:

<?PHP
display_message( );
function display_message( ) {
$display_text = "display message";
print $display_text;
}

?>

that all....
N/NOTE:how about we declare a variable inside the function.....then directly display that variable,i meant display it without calling the function..try it!taste it! 
 

No comments:

Post a Comment