faqts : Computers : Programming : Languages : PHP : kms : General : Variables

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 7 people (57%) answered Yes
Recently 4 of 7 people (57%) answered Yes

Entry

how can i define variable

Jul 10th, 2003 10:54
Philip Olson, fakhruddin josawa,


A pretty vague question :)  There are a million ways to define 
variables, for example:

  $foo = "somevalue";
  echo $foo;

  http://www.php.net/language.variables

Or, let's say you want to define a variable through the HTTP request, 
like through GET:

  http://www.example.com/yourscript.php?bar=somevalue
  echo $_GET["bar"];

  http://www.php.net/variables.external

Or maybe a cookie:

  setcookie("baz", "some value", time()+424242);
  echo $_COOKIE["baz"];

  http://www.php.net/setcookie

Or maybe you're a little confused about variable scope in PHP (you 
wouldn't be the first), consider this manual page:

  http://www.php.net/variables.scope

The manual discusses various ways to define variables, so be sure to 
read the manual.