How To Learn PHP

How To Learn PHP

Since PHP is the most popular server side programming language on the Internet, many people desire to learn it. When PHP emerged, it allowed programmers to create php files for which you could combine various languages(PHP, HTML, CSS,  Javascript) into one file.  This was very convenient for a web designer or developer. Since PHP is mainly used to output HTML / CSS, it is recommended to have a decent knowledge of these languages since you will actually work with various codes in one swoop. With editors like Notepad++ which highlight various languages like HTML and PHP, it easy to see detect what code is what. People with web design skills but little PHP knowledge should be able to see the difference. If not, they should be able to determine the difference in 2 minutes. When a PHP programmer works with HTML, HTML can be located inside or outside the PHP tags. Code outside of tags is just plain old HTML while code inside quotations gets parsed by PHP on the server.  If single quotes are used, the HTML will look just as it would in plain old HTML. But, if the programmer uses double quotes, the double quotes in the HTML use backslashes.

Since PHP is mainly used to output HTML, the whole skillset is a bonus. Often, a team has members which have varied strengths. But, none should be totally  lost when looking at the code. A designer should know where to edit his html and the web developer should have a grip on everything he sees.

First Steps
PHP code exists between a starting and ending tag. The staring tag is <?php and the ending tag is ?>. Create a file called first.php and write the code below into the file. Then, save it and open it in a browser.

echo “PHP is fun!”;

echo ‘<br/>’;

 echo ‘Isn’t it?’;

PHP is fun!
Isn’t it?

The codes below show how to create a link.  

Single Quotes
echo ‘<a href =”myfile.php”>Click Here</a>’;  
//Yields :
Click Here

Double Quotes
echo “<a href =\”myfile.php”>Click Here</a>\”;  
//Yields: Click Here