iSelfSchooling.com - Since 1999  References  |  Job Openings  |
    Home  | Search more  | Oracle Syntax  | Instructor-Led in Class   | (Members to access to VIDEOS)
 

Copyright & User Agreement

   Suggestions Email2aFriendHomepage us! |  Bookmark

Services

  Vision/Mission

  Services

  Biography

  Contact Us

 FREE Training

  Start...

  SQL

  PL/SQL

  Forms 

  Reports

  DBA Fundamentals

  Performance

  Prepare for OCP

  ShareUrNotes

...

  Acknowledgement

  Who is who

  University Directory

  Links...

 

 

 

What are variables or parameters in PHP and how to use them? 

More Resources by Google:

What are variables or parameters in PHP and how to use them? 


Variables or Parameters are temporary containers for data in memory. We have predefined variables and user variables. A predefined variable is a type containing information about the Web server application such as Apache, the Web server operating system such as Linux, Mac, or Windows (Environmental variables), or the PHP module uses. The following is an example of using a PHP’s predefined variable.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitionl.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>The PHP example page, using predefined variable!</title>
</head>

<body>

/* “pre” makes the generated PHP information more legible. $GLOBALS variable
contains all the variables accessible to the script (predefined and user).
*/ 
<pre> 
<?php 
print_r ($GLOBALS); 
?>

</body>
</html>

Save the file in your server running PHP and run the script to see the output.

The following is an example of using a PHP’s user defined variable. When you defined a user defined variable, you must following the following naming convention:
· Must be preceded by $,
· Following with a letter (A-Z, a-z) or an underscore (_),
· Don’t use space or be the same as predefined variables, and 
· They are case-sensitive.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitionl.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>The PHP example page, using user defined variable!</title>
</head>

<body>

<pre> 
<?php 
// my variables - My name and age.
   $my_name = ‘John’;
   $my_age = 84;
   print_r ($GLOBALS); 
?>

</body>
</html>

 

 

 
 
Google
 
Web web site