PHP -Pass für Referenz
<?php
// Declair function assigns a new value to
// $string variable and prints it
function return_string( &$string ) {
//build return string var
$return_the_string = $string . "- returned STRING";
//modify the string var
$string = $string . "- passed byREF";
// you could print or return the string aswell
//print( $string );
return $return_the_string ;
}
// EXAMPLE 1 ----------------------
$string = "1-Input string ";
return_string( $string ); //call function
print( $string ); //print string with new text
# EXAMPLE 1 OUTPUT:
# 1-Input string - passed byREF
// EXAMPLE 2 ----------------------
$string = "2-Input string ";
$returned_string = return_string( $string ); //call function
print( $string); //print string with new text
print( $returned_string ); //print string with new text
# EXAMPLE 2 OUTPUT:
# 2-Input string - passed byREF
# 2-Input string - returned STRING
?>
Anxious Albatross