- BASICS
- Quotes
- Constants
- Control Structures
- Reference
- Number Systems
- VARIABLES
-
Definition
- Variable Variable
- Exists
- Type Casting
- OPERATORS
- Aritmetic
- Bitwise
- String
- Comparison
- Logical
- FUNCTION
- Definition
- Anonymous
- Reference
- Variable Arguments
- ARRAY
- Basics
- Operations
- Create
- Search
- Modify
- Sort
- Storage
- STRING
- String Basics
- String Compare
- String Search
- String Replace
- String Format
- String Regexp
- String Parse
- Formating
- Json
- STREAMS
- File Open
- Read File
- Read Csv
- File Contents
- Context
- Ob_start
- OOP
- Object Instantiation
- Class Constructor
- Interfaces, Abstract
- Resource Visibility
- Class Constants
- Namespaces
- HTTP
- Headers
- File Uploads
- Cookies
- Sessions
Type
PHP will implicitly change the type of a variable as needed (loosely typed).
/**
* PHP will implicitly ...
* change the type of a variable as needed
*
* This contrasts with strongly typed languages,
* like C and Java
*/
$a = "abc";
$b = 0 + "1";
$c = new ArrayObject();
echo gettype($a); // string
echo gettype($b); // integer
echo gettype($c); // object
Naming
Variables must start with a letter or an underscore.
/**
* Variables must be named using only ...
* letters, numbers and underscore.
* $name_/ - invalid name
*
* Variables must start with a letter or an underscore
* $1_name - invalid start
*/
$name = 'valid'; // valid name
$_name = 'valid'; // valid start
Case
Variables names are case sensitive.
/**
* In PHP Variables are one of only two identifier types ...
* that are case-sensitive
*
* The other are constants
*/
$Name = "John";
const NAME = "Bob";
var_dump(isset($name)); // false
//echo name;
//Undefined constant: name
Last update: 531 days ago