PHP Tutorial #1

In hopes of helping the community better understand code I am going to present PHP in is rawest form. I learned a basic understanding if the code when I was commuting to Ivy Tech Community Collage but I never took the time to study it and break it down so that my viewers and I could get a better understanding.

PHP is a server side scripting language. It is not that you can’t use PHP in your HTML however it is a language that goes past structure or layout but goes into logic.

As a requirement you need to be using a server that allows you to use PHP. Many of the free server hosting sites limit your access and you cannot use PHP. If you are uncertain ask the administrator of your web host. In most cases if the admin say you do not have access than you cannot install PHP. The reason is because you are more than likely running on a FTP server on a main host. For example if I so felt intitled to I could allow users to make web pages on Jdudesign and limit their space and allow them no access to PHP. Due to this restriction a user cannot install PHP on the server and expect it to funtion. If however you have a running server that allows the use of PHP you can begin the process of coding using a server side programming language.

On my vouage to learn PHP I started using http://www.w3schools.com for a basic understanding of the concepts of PHP. Accoring to their site they have defined PHP as the following:

  • PHP stands for PHP: Hypertext Preprocessor
  • PHP is a server-side scripting language, like ASP
  • PHP scripts are executed on the server
  • PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
  • PHP is an open source software
  • PHP is free to download and use

W3Schools informs their readers that they should have a basic understanding of Javascript before voaging into uncharted territories, however a web developer sometimes needs to break the rules of commonality in order to become more of a proffessional.

This first tutorial is going to be very basic and is going to be really simple. PHP can be implimented into your HTML files but for this tutorial we are going to have a seperate file called index.php. Inside this file we are going to add two things: a opening and closing tag and a command that tells the php to add a line of text. Remember this is not HTML instead this is code a server is following.

To use PHP you need to have a opening and closing tag JUST like HTML.

<?php
$>

The only difference is adding question marks and not slashes and allowing there to be air flowing between a PHP and question mark.

The next step is adding a simple code that allows text to show up on your page.

echo "yourtext";

As with CSS you are going to be using the semi-colin to seperate commands. The echo or print funtion tells your server to display the following text to your website. All in all we have the following:

<$php
echo "hello world";
$>

The following tutorial has been done on Jdudesign.