Docsity

Understanding Variables in PHP - Prof. Zinga, Slides of Applications of Computer Sciences

Partial preview of the text

Download Understanding Variables in PHP - Prof. Zinga and more Slides Applications of Computer Sciences in PDF only on Docsity!

VARIABLES IN PHP

Variables in PHP

  • (^) PHP variables must begin with a “$” sign
  • (^) Case-sensitive ($Boo != $Boo != $Boo)
  • (^) Global and locally-scoped variables
    • (^) Global variables can be used anywhere
    • (^) Local variables restricted to a function or class
  • (^) Certain variable names reserved by PHP
    • (^) Form variables ($_POST, $_GET)
    • (^) Server variables ($_SERVER)
    • (^) Etc.

$_POST

  • (^) Data is packaged inside the body

• MORE SECURE

  • (^) No data limit
  • (^) Cannot bookmark
  • (^) GET requests are not cached
  • (^) Better for submitting credentials

Variables Usage

$foo = 25; //Numerical variable

$bar = “Hello” // String variable

$foo = ($foo * 7); // Multiple foo by 7

$bar = ($bar * 7); // Invalid expression