PHP Flashcards
Acronym for PHP
PHP Hypertext Preprocessor
Original acronym for PhP
Personal Home Page
Basic output statements in Php
Echo and print
Variable names are case sensitive.
YES or NO ?
Yes
$_GET
contains value of input being transported through GET method
$_ENV
contains server environment variables
String Concatenation
$string3 = $string1 . $string2;
Function ‘filetype’
checks if it’s a file or directory echo "/etc/passwd is a " . filetype('/etc/passwd'); // is a file echo "/etc is a " . filetype('/etc'); // is a dir
Function ‘gettype’
checks the type of variable $var1 = 5; // integer echo gettype($var1);
‘header’ function
used to redirect browser to another location
header(“Location: http://ict.senecacollege.com”);
$_SERVER[“REMOTE_ADDR”]
$_SERVER[“SERVER_NAME”]
$_SERVER[“SERVER_ADDR”]
User’s IP address
Server’s name:
Server’s address
strlen() function
to return the length of a string
strpos() function
to search for a character/text within a string
- If a match is found, this function will return the character position of the first match.
- If no match is found, it will return FALSE.
echo strpos(“I love Linux”,” Linux”); //returns 7
Date functions
// to show date in numbers eg. 21 11 10 echo date("d m y"); // to show date in numbers with hyphen separators eg.21-11-10 echo date("d-m-y"); // to show date in words eg. Sun Nov 2010 echo date("D M Y");
Time functions
//time (12 hr clock) separate by colon using a date function echo date("h:i:s"); //time (24 hr clock) separated by colon using a date function echo date("H:i:s");