User Tools

Site Tools


documentation:php

~~TOC~~

Lab46 Tutorials

PHP

Hyper Text Preprocessor

PHP (Personal Home Page) is a scripting language used to produce dynamic web pages. It is put into html pages to give them more functionality. There is no compiling necessary, the web server interprets the code at run time.

First Web Page with PHP

<html>
    <head>
        <title>My page with PHP</title>
    </head>
    <body>
    <?php
        echo "This is a hello world page!"
    ?>
    </body>
</html>

Basic Commands

Variables and Comments
  • $ - variables (do not need to be declared)
  • / / - comments
Common Functions
  • if () - decision
  • else () - alternate to if
  • eval () - evaluate text string
  • Array () - creat an array
  • time () - outputs time
  • date () - formats time output
  • echo () - output to page
  • include () - include external files
  • system () - call the system to execute a command
  • shell_exec - call the system to execute a command
Regular Expressions
  • / - escape character
  • ^ - start of string
  • $ - end of string
  • . - and single character
  • a? - 0 or one of a
  • a* - 0 or more of a
  • a+ - 1 or more of a
  • (y|z) - y or z
  • (…) - group selection
  • [xyz] - range
  • [^xyz] - ont in range
documentation/php.txt · Last modified: 2010/05/20 14:19 by triley2