Sunday, January 9, 2011

The variable in PHP

Firstly,hye!!!how r u??r u ready for a new adventure with me!!
shall we go to the world of PHP!!


ok,for this post i will introduce to u the variable for PHP,okey,this variable is quite similar with others programming variable such as C ,C+ and java .it just plus with this symbol '$' at front of variable.for EXAMPLE


                           $people_test=1; 


that one if you want to put that variable with the number but with words,we must use the double or single quote like this :


                          $style="topman";


                          $chocolate='ice cream';
                          $citizen_move='foot';


plus it also can do like this:


                                $number1=1;
                                $number2=2;
                                $total=$number1+$number2+5;


Then to the coding!!first of all,u need to open the Notepad or Textpad and copy this code :



<html>
<head>
<title>Getting with PHP Variables </title>
</head>
<body>

<?php print("Hello world!"); ?>
</body>
</html>


then save ur page as Variable.php.Then put this file in 'www' folder which is inside the 'EasyPHP5.2.10' folder


to open 'www' folder:


Open Local Disk C>open Program Files>EasyPHP5.2.10(i use version 5.2.10)>www

ok,n then test it by write this link on the web browser:


http://127.0.0.1/Variable.php



or this:


http://localhost/Variable.php




If you've created a folder inside the 'www' folder, then the address to type in your browser should be like this:

http://127.0.0.1/YourFolderName/Variable.php


For this code,the PHP script is only one line long,the rest is HTML script:
            
 <?php print("hello world!"); ?>


okey,shall we examine this line.so,in order to instruct the browser to display things on the page, we've used print( ).The browser will print what between the round bracket.


Ah..haa,i got an idea,how about we just use variable to display it like this:


 <?php 


/*---THE COMMENT IS JUST LIKE C+ PROGRAMMING!!---*/
 
$test_word="hello world!";


print($test_word); 


?>


just test it for urself,is it work?please comment me below


N/NOTE:practice make perfect!!,next post, i publish the question!!!hahaha r u happy ryte!?i hope so...



No comments:

Post a Comment