indiWiz.com
SiteSearch:
Jump:

Site Map | WizTools.org | jCraze Blog
Web Developer's Den!
Home : WDD : ServerSide
This Article...
Print Version
Add Comment
View Comments
ServerSide
Apache on Linux
Apache User Directory Configuration
PostgreSQL Configuration
CGI: What and How?
PHP Jump Start Guide
Arrays in PHP
PHP and HTML Forms
Variable Passing in PHP
PHP 'include'
Drop-down Menu Navigation in PHP
Edit Your Site Online Using PHP
PHP MySQL Polling System
Dynamic, Search Engine Friendly Pages
Quot Ticker Using SSI
Regular Expressions Reference
PHP File Browser
PHP DB Deletion/Approval Script
Sections

Commniquè
Sign Guestbook!
Read Guestbook!
MailMe!

PHP: Subhash's Jump Start Guide

Before We Start ...

According to Rasmus Lerdorf (creator of PHP), PHP is "a server-side, HTML-embedded, cross-platform scripting language". To my knowledge, PHP when expanded becomes "PHP Hypertext Pre-processor". You can get the latest distribution of PHP from PHP.net site. PHP files are to be saved with the extension .php.

Syntax:

<?php
//statements go here;
?>

or

<?
//statements go here;
?>

Comments

  1. Single line comment:
    • // -> C++ style
    • # -> shell script style
  2. Multi-line comment
    /*comment line 1
    comment line 2*/

Variables

  • case sensitive (Note that function names [both user defined & predefined] and keywords are not case sensitive.)
  • preceded by a '$' symbol
  • variables need not be initialised using declarative statements

Strings

They cannot be concatenated by the '+' operator. You have to use the '.' operator. Eg.: -

<?php
$str = "This is a string";
$str = $str." with some more text";
?>

String is an array. Eg. of getting the first character of a string: -

$str = "This is a test";
$first = $str[0];

Last character of string: -

$last = $str[strlen($str)-1];

Quotation

Strings are to be placed within double quotes or single quotes. When double quotes are used, all C language escape characters work. In single quotes only '\' & '\\' work.Eg.:

<?php
$name = "Subhash";
echo "$name is a GREAT boy";
echo '$name is a GREAT boy';
?>

The result will be:

Subhash is a GREAT boy
$name is a GREAT boy

Output

echo, print and printf() are the key-words and function used for printing the output. The printf() function has the same syntax as in C. Here is a full example:

<HTML>
<BODY>
<?php
  echo "<h4>Hello World!</h4>";
?>
</BODY>
</HTML>


User Comments

Add Comment

[Quick Stats: Number of main threads: 0, Number of sub-threads: 0]

Sign Guestbook | Who is Subhash?
The contents of this site are copyright© 2000-2008, indiWiz.com. All Rights Reserved.