Click Here To Learn Php In Less Than 30 Days
Learning to write PHP simple code should be fun and simple. PHP is one of the easiest and powerful language in the internet. It stands for PHP Hypertext Preprocessor and is a server-side language. This means that the script is run on your web server, not on the user’s browser, so you do not need to worry about compatibility issues. PHP is relatively new (compared to other languages such as C, Perl (CGI) and Java) but has quickly become one of the most popular scripting languages on the internet. Another good thing about it is it’s an open-source language.
As mentioned earlier, PHP is a server-side scripting language. It means that, although your users will not need to install new software, you will need to have PHP installed on your web host server. It should be included as part of your package but if you don’t know if it is installed you can check and find it out using the sample code below. If you server does not support PHP you can ask them to install it for you since it is free to download and install. Along with the PHP you would need a server such as APACHE. Also take note that PHP could run in any platform such as windows or linux. MYSQL is optional though. But most PHP uses MYSQL as its database. It most cases if you would need PHP there are some packages that has all the components needed like linux, apache, mysql and php which stands for LAMP.
Writing PHP code is actually very simple. No need for any special software, except for a text editor (like Notepad in Windows) as simple as that or you can also download other php editor with some extra added features to it which is very helpful as a tool. Save and run the file on your browser and you have now your php code.
Let’s examine the sample code below.
<?
$var = “hi”;
echo “hello world”;
echo $var;
phpinfo();
?>
A PHP code is always enclosed with open and close tags ‘<?’ and ‘?>’. The next line we have a variable initialization of $var with ‘hi’ as a value. Unlike on other languages which you would need to declare the variable first before you can use it. In PHP you can use the variable right away without declaring it. And as you notice at the end of the 1st line we have ‘;’ semi-colon that indicates the end of the statement like on C Language.
Now let’s go to the next line. Here we have simply echo the string ‘hello world’ which will print it out or display on the browser. And after that line we have the variable $var initialize earlier which contains the value string ‘hi’ as being printed out the same as the previous line.
On the last line, we have the function phpinfo() which will print out the server information of php, apache, and mysql as mentioned earlier. So there you go as simple as the codes above you now have your php simple code. You just need to practice and try other codes with some use of functions and later you’ll find yourself creating more complex code useful for any purpose you may need.




