Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

PHP programming - chapter 6: Function

function functionName(function_parameter){
      function body here
}


example:
string name="SAM";
function print_name(string name){
      print ("my name is $name.");
}
    to call this function just:
.print_name($name);
you will see a result as;
my name is SAM.

PHP programming - chapter 4: condition

Using Switch Statement

switch($_GET[action]//get input and save to action
{
    case "start":
         print ("select start");
         break;
    case "stop":
         print ("select stop");
         break;
    default:
         print ("NO choice");
         break;
}

PHP programming - chapter 3

valid constant and variable that important:
Add caption


Variable
String:
<?
$var1="sam";
print "my name is $var1";
?>


Boolean:
$var1=true=1;
$var2=false=0='';

Special Variable:

some variable you can not use it as it has its own value:
$GLOBLAS
$_POST
$_GET
$_REQUEST
$_SERVER
$_COOKIE
$_FILES
$_ENV
$_SESSION

Variable Variable
Example:
<?
$var1=""john";
$var2="SAM";
print ("you choose $$_GET["variable"] to be your advisor");
?>

Note: two dollars sign: the input will print and ask you to input value for variable by using $_GET, and after get input to $_GET, it will be displayed to the print line.In this case, you have only two choice to replaced variable is var1 and var2. Otherwise, result will not get any variable to display.
 

Personal I.T blogs Copyright © 2011 -- Template created by O Pregador -- Powered by Blogger