Search The Website


Web development links & resources


PHP, PPHP Tutorial, Please add your comments, and Useful Links.

 

 
 PHP Tutorial

PHP Personal Home Page PHP) is mainly focused on server-side scripting, so you can do anything any other Computer-Generated Imagery (CGI) program can do, such as collect form data, generate dynamic page content, or send and receive cookies. But PHP can do much more.

There are three main areas where PHP scripts are used.

  • Server-side scripting. This is the most traditional and main target field for PHP. You need three things to make this work. The PHP parser (CGI or server module), a web server and a web browser. You need to run the web server, with a connected PHP installation. You can access the PHP program output with a web browser, viewing the PHP page through the server. All these can run on your home machine if you are just experimenting with PHP programming. See the installation instructions section for more information.
  • Command line scripting. You can make a PHP script to run it without any server or browser. You only need the PHP parser to use it this way. This type of usage is ideal for scripts regularly executed using cron (on *nix or Linux) or Task Scheduler (on Windows). These scripts can also be used for simple text processing tasks. See the section about Command line usage of PHP for more information.
  • Writing desktop applications. PHP is probably not the very best language to create a desktop application with a graphical user interface, but if you know PHP very well, and would like to use some advanced PHP features in your client-side applications you can also use PHP-GTK to write such programs. You also have the ability to write cross-platform applications this way. PHP-GTK is an extension to PHP, not available in the main distribution. If you are interested in PHP-GTK, visit » its own website.
The following is PHP script to write the sentence: Hello, World!

<!DOCTYPE html>
<html>
      <head>
           <title>Hello!</title>
      </head>

     <body>

          <?php
               echo("Hello, World!");
          ?>
     </body>
</html>

 

Note: For quick results, you need a good PHP editor with a split view option to allow the user to code in Code view and preview in Design view without the hassle of switching from the design and code view tabs for each review. By using such editor you will very quickly learn and familiarise your self with PHP structure, statements and functions. I am using Rapid PHP editor, it is fast, complete all-in-one software for coding PHP, HTML, CSS, JavaScript and other web development languages with tools for debugging, validating, reusing, navigating and formatting your code. After developing and debugging your PHP code, save it as PHP file, and upload the PHP and data files to your server.

Can I combine PHP with HTML? yes, PHP is an HTML-embedded server-side scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly. (Make sure that your hosting offers its clients PHP and HTML services). When building a complex page, at some point you will be faced with the need to combine PHP and HTML to achieve your needed results. At first point, this can seem complicated, since PHP and HTML are two separate languages, but this is not the case. PHP is designed to interact with HTML and PHP scripts can be included in an HTML page without a problem. In an HTML page, PHP code is enclosed within special PHP tags. When a visitor opens the page, the server processes the PHP code and then sends the output (not the PHP code itself) to the visitor's browser. Actually it is quite simple to integrate HTML and PHP. A PHP script can be treated as an HTML page, with bits of PHP inserted here and there. Anything in a PHP script that is not contained within <?php ?> tags is ignored by the PHP compiler and passed directly to the web browser. If you look at the example below you can see what a full PHP script might look like:

<!DOCTYPE html>
<html>
      <head>
           <title>Combining PHP and HTML</title>
      </head>
      <body class="page_bg">
           Hello, today is <?php echo date('l, F jS, Y'); ?>.
     </body>
</html>

The code above is simply HTML, with just a bit of PHP that prints out today's date using the built-in date function. As mentioned above, all of the plain HTML in the code above will be ignored by the PHP compiler and passed through to the web browser untouched.

If you want, you can create a PHP script that only has HTML in it and no <?php ?> tags, and it will work just fine.
More advanced techniques:
<html>
<head></head>
<body>
<ul>
<?php for($i=1;$i<=5;$i++){ ?>
<li>Menu Item <?php echo $i; ?></li>
<?php } ?>
</ul>
</body>
</html>

and the result is:

•Menu Item 1
•Menu Item 2
•Menu Item 3
•Menu Item 4
•Menu Item 5

PHP in HTML - file extensions: When a given file contains PHP code, it must have a PHP extension. In most cases this is .php.

The Standard PHP Library (SPL): SPL provides a standard set of interfaces for PHP. The aim of SPL is to implement some efficient data access interfaces and classes for PHP. Functionally it is designed to traverse aggregate structures (anything you want to loop over). These may include arrays, database result sets, xml trees, directory listings or any list at all. Currently SPL deals with Iterators. http://www.phpro.org/tutorials/Introduction-to-SPL.html To see all the classes available to SPL, this simple snippet will show you.

<?php
// a simple foreach() to traverse the SPL class names
foreach(spl_classes() as $key=>$value)
{
echo $key.' -&gt; '.$value.'<br />';
}
?>

This will provide you with a list something like this:
•AppendIterator -> AppendIterator
•ArrayIterator -> ArrayIterator
•ArrayObject -> ArrayObject




.....
etc.

Back to top

 PHP Examples

 

You may learn PHP by examples:

(1) W3 School , and

(2) Code Academy both website have comprehensive list of PHP examples in tutorial  manner enjoy your coding.

 

Back to top

  Guestbook

Back to top

 Useful Links
Learn PHP in 15 minutes (You tupe 15 minutes video).

 

Web Development Resources

Coding Help

Development Tools

Collection of some of the most useful web development resources

Here you will find carefully picked links to thebest tutorials, most useful references and official specifications of the most important web programming languages.

Browse

Hashim IT Solutions  |  RWD  |  HTML  |  CSS  |  JavaScript  |  PHP  |  Bootstrap  | About  |  HashimWebSite  |  ExpertGrabber  |  ContactUs  |  Sitemap  |

Back to top