First Script - Meeting 2

Before we start coding PHP, it s better to know the software environment needed to work with our scripts.
They are:
PHP, to interpret our PHP scripts.
Web server, to serve request and respond from and to users. There are many webs ervers which can serve with php scripts and one of the most popular is apache.
MySql, this is a database which is commonly paired to PHP and mostly used by php developers.

Those 3 is commonly distributed as one bundle (3 in 1). We can find it in the internet or from google with key words xampp, appserv, etc. By installing one of those bundles we will have php, apache, and mysql with a simple little setup.
One more, what we need to code is an editor. Basically we can write on any editor like notepad, wordpad, etc. Of course there are many editors which is spesifically for php and we can easily find it in the internet or by googling.
So we will not discuss about it anymore because I am going to focus in php scripts tutorial.
Well, it s time to code php now and pay attention to the script below:

<?php
print("Hello World!");
printf("<br>Today is %s ", Date("d F Y"));
$nama = "Every body"; //creating a variable must be started with $
print("<br><br>Good morning $nama, have a nice day!");
/*
this is for multilines comments
*/
printf("<hr><br>Good afternoon %s, see you tomorrow morning",$nama);
?>


save it as one.php in folder for example: C:\AppServ\www\phpisus\basic\one.php
Because i used bundle from Appserv, all files should be saved under folder \www\ if you are using another bundle probably it is under folder htdocs. Please read for each bundle carefully.
Going back to the scripts. After saving it, open your browser and point to http://localhost/phpisus/basic/one.php yous should see:


Well, it is the first script. The most principal thing of PHP code is that any PHP code must be between <?php and ?> bracket and each line of PHP commands must be ended with a semicolon (;).

For the PHP commands used above please refer to the result to analyze the command's functions in PHP.

Any question can be posted as comments and so do the answers. See you in the next meeting.

No comments: