PHP

 Home  Computers & Internet  Web Programming PHP
What is PHP?
Echo
Comments
Variables
Constants
Data Types
number_format()
Character Strings
Mathematical Operators
Comparison Operators
Logical Operators
Joining Strings
explode()
implode()
strtolower()
strtoupper()
strlen()
ucfirst()
ucwords()
strrev()
str_replace()
str_repeat()
trim()
strip_tags()
addslashes()
stripslashes()
strpos()
strrpos()
nl2br()
isset()
unset()
empty()
POST
GET
If Statements
If Else Statements
Elseif Statements
Switch Statements
For Loops
While Loops
Do While Loops
Foreach Loops
File Create
File Open
File Read
File Write
File Delete
fgets()
file_get_contents()
Date & Time
$_SERVER
Sessions
Cookies
Arrays

HOW TO COMMENT OUT YOUR SCRIPT IN PHP

When coding in PHP, it is customary to insert special comments to describe what the codes does or any other useful information. This is especially important if you look back at this script some time later and these comments will instantly tell you what the script or a certain line of code was for.

Comments are embedded in the script itself and co-exist with your actual coding. However, there are certain ways to do this so as not to interfere with the actual execution of your script and cause errors.

Using # or //

<?
echo "John Smith";
# This is a comment line
// This is also a comment line
?>

You can # or // in the same line as your code as below:

<?
echo "John Smith";  # This is a comment line
echo "Nancy Wells";  // This is also a comment line
?>

If you use # or //, a new line of comment must also start with # or // as below:

<?

echo "John Smith";  # This is a comment line that extends
# Over two lines
echo "Nancy Wells";  // This is also a comment line
// that extends Over two lines
?>

A simple method for long comments that extends multiples lines is:

<?

/* This is my first php script to demonstrate comments.
It is very simple to use this method if you
Have long comment lines.
Done by: John Smith
Date: 24 May 2007
*/
echo "John Smith"; 
?>

If you want to emphasize important comments, use this:

<?

##############################################
##This is my first php script to demonstrate comments.##########
##############################################
echo "John Smith"; 
?>

Home | Privacy Policy | Terms Of Use | Contact Us