I have produced some good php programmers and they are doing well in their respective companies, I am very happy for them, it gives me great satisfaction. Those are my close friends.
I believe, at sisnolabs I will make some better php programmers in coming years.
We have been working on open source technologies at sisnolabs and that inspire me to write php tutorial for beginners, this tutorial will have many posts. It will be a great achievement if I can tech them little php through my tutorial.
Who can follow this PHP tutorial
- if you know some html, C programming language and SQL
- if you are interested for web development
- if you support open source (even by using its products)
Get server ready
Have apache server ready (configured with php) in your machine to execute php scripts. Install xampp or wamp to your machine, it is the bundle of apache, php, mysql. (I believe you people can install it in your machine easily…Google or Bing it to download)
PHP editor
Have good php editor to write PHP code, here is a list of php editors
First PHP script – “Hello World”
- every php script has to start with <?php and end with ?> (however it is changeable)
- php statements should end with semicolon (;)
<?php
echo "Hello World";
?>
save this php script as index.php at root directory (document_root), it could be xampp/htdocs/ or wamp/www/ or var/www/public_html/
now use your browser (Firefox, Chrome, Internet Explorer, Safari, Opera) to access the script, URL can be like http://localhost/index.php or http://your_server_name/index.php
PHP variable
- do not need to declare data type for php variables
- PHP guesses the data type according to variable’s value
- every php variable should start with ($) sign
<?php
//numeric variable
$variableName = 100;
//string variable
$variableName = "hundred";
?>
Comments on PHP code
- single line commenting can be done using // or #
- multiple line commenting start with /* and end with */
<?php
//$strName = "sisnolabs";
#$arrColors = array();
/*
if (count($arrColors) < 1) {
echo "colors are missing";
}
*/
?>
I appreciate your feedbacks. Stay tuned for next session.