Given a string containing a path to a file, this function will return the base name of the file.
$base = basename($_SERVER['PHP_SELF']);
Converts applicable characters into their html entities. I.e > changes to >
$noHTML = htmlentities("<br />"); print $noHTML; //this will print: <br />
Escapes all single quotes, double quotes and backslashes
$str = "Is your name O'reilly?"; // Outputs: Is your name O\'reilly? echo addslashes($str);
Searches and replaces all occurances of a string
// Provides: $bodytag = str_replace("%body%", "black", ""); // Provides: Hll Wrld f PHP $vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U"); $onlyconsonants = str_replace($vowels, "", "Hello World of PHP"); // Provides: You should eat pizza, beer, and ice cream every day $phrase = "You should eat fruits, vegetables, and fiber every day."; $healthy = array("fruits", "vegetables", "fiber"); $yummy = array("pizza", "beer", "ice cream"); $newphrase = str_replace($healthy, $yummy, $phrase);
Returns the portion of string specified by the start and length parameters
$rest = substr("abcdef", 1); // returns "bcdef" $rest = substr("abcdef", 1, 3); // returns "bcd" $rest = substr("abcdef", 0, 4); // returns "abcd" $rest = substr("abcdef", 0, 8); // returns "abcdef"NEXT