Escolar Documentos
Profissional Documentos
Cultura Documentos
escaping them
$favoriteAnimal = cat;
echo My favorite animals are {$favoriteAnimal}s;
This produces the expected result:
My favorite animals are cats
If you need to extract a sequence of characters
from a string, you can use PHP s substr() function.
This
function takes the following parameters:
The string to extract the characters from
The position to start extracting the characters. If
you use a negative number, substr() counts
backward from the end of the string
function setup() {
global $myGlobal;
$myGlobal = Hello there!;
}
function hello() {
global $myGlobal;
echo $myGlobal < br/ > ;
}
setup();
hello(); // Displays Hello there!
you can also access global variables using the
( & ) before
the parameter name within the function definition:
function myFunc( & $aReference ){
// (do stuff with $aReference)
}
you place an ampersand before the function name
in your function
definition. Then, when you return a variable with