|
    |
|
|
PHP Course Part I
Before start of building big Internet applications, one must learn basic of language . Because I choose PHP for start I will show some basic of PHP programming. If you want to write some pages in PHP language you need to make file with extension .php (of course you can reconfigure server for other extensions, but using this you will be sure that your script will work) PHP files are normal text files, so you don’t need estra applications to write PHP scripts, Notepad is enough. Of course I recommend Notepad++ :) Maybe later I will write how to prepare Notepad++ to be helpful with PHP programming. In .php file you need to inform server that this text file contain some PHP script. You can make it with several way (this what I hate in PHP, there is so many ways to obtain the same result, and some are wrong ) <?php code ?> This is one way, and I recommend it. There is of course short version with only <? ?>, but you need to configure PHP to use short tag, so normal version is better, because it always work. Next step is to write something. Everyone start with Hello World program, so we cannot be worst :) <?php echo ‘Hello World’; ?> From this program you can learn many thing :) First after all commands you need add “;“, second if you want to print some text on page you need to use echo command. Of course like I mention before in PHP there is several ways to do the same thing, instead of print you might also use print. The main difference between this commands is that print return value. If everything goes right, print will return 1 (TRUE). If you want test it you can write: <?php $var = print ‘Hello World’; echo $var; //Return TRUE ?> I will write about functions in PHP later, but now you must know that print and echo aren’t functions!!! They are language construct. I will discuss later more about it. From this short script you can learn about comments in PHP. If you want comments one line of code you need to add //, and from this point to end of the line everything will be commented. Sometimes you want comment more for this you can use /* */. Everything between this two will be commented. When yo using echo or print you can use “” or ”. The main difference between this two is that all variables between “” will be replaced by they value. <?php $foo = ‘World’; echo “Hello $foo “; // print Hello World echo ‘Hello $foo’; // print Hello $foo ?> The main power of PHP is that it can be mixed with PHP: <html> <head> <title>Topic</title> </head> <body> <?php echo ‘Hello world’; ?> </body> </html> There is some trick if you have short_tag enable on the server. If you have declared variable $var with value Hello World you can change previous code in: <?php $var = ‘Hello World’ ?> <html> <head> <title>Topic</title> </head> <body> <?= $var ?> </body> </html> It will be very helpful when you will work with templates.
|
|
 |
|
No reactions yet.
Please login or sign up to rate this intel.
Please login or sign up to add a comment.
The copyright for this content entitled "PHP Course Part I" has been specified by the contributor as:
All Rights Reserved
This content may not be copied, distributed or adapted by anyone under any circumstances.
|
 |
|
This intel was contributed by nexik
|
May, 2012
2008
January, February, March, April, May, June, July, August, September, October, November, December
2009
January, February, March, April, May, June, July, August, September, October, November, December
2010
January, February, March, April, May, June, July, August, September, October, November, December
2011
January, February, March, April, May, June, July, August, September, October, November, December
2012
January, February, March, April, May
|
|
Not a member yet?
Qondio is a powerful network for making it online. If you have a website to
promote, we can help.
Sign up and get in on the action.
|
|
Welcome to Qondio! Discover the awesome power this network can deliver by going to our About page. Or you could skip straight to the Sign Up form.
|
|