Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

echo(3) [php man page]

ECHO(3) 								 1								   ECHO(3)

echo - Output one or more strings

SYNOPSIS
void echo (string $arg1, [string $...]) DESCRIPTION
Outputs all parameters. echo is not actually a function (it is a language construct), so you are not required to use parentheses with it. echo (unlike some other language constructs) does not behave like a function, so it cannot always be used in the context of a function. Additionally, if you want to pass more than one parameter to echo, the parameters must not be enclosed within parentheses. echo also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. Prior to PHP 5.4.0, this short syn- tax only works with the short_open_tag configuration setting enabled. I have <?=$foo?> foo. PARAMETERS
o $arg1 - The parameter to output. o $... - RETURN VALUES
No value is returned. EXAMPLES
Example #1 echo examples <?php echo "Hello World"; echo "This spans multiple lines. The newlines will be output as well"; echo "This spans multiple lines. The newlines will be output as well."; echo "Escaping characters is done "Like this"."; // You can use variables inside of an echo statement $foo = "foobar"; $bar = "barbaz"; echo "foo is $foo"; // foo is foobar // You can also use arrays $baz = array("value" => "foo"); echo "this is {$baz['value']} !"; // this is foo ! // Using single quotes will print the variable name, not the value echo 'foo is $foo'; // foo is $foo // If you are not using any other characters, you can just echo variables echo $foo; // foobar echo $foo,$bar; // foobarbarbaz // Some people prefer passing multiple parameters to echo over concatenation. echo 'This ', 'string ', 'was ', 'made ', 'with multiple parameters.', chr(10); echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . " "; echo <<<END This uses the "here document" syntax to output multiple lines with $variable interpolation. Note that the here document terminator must appear on a line with just a semicolon. no extra whitespace! END; // Because echo does not behave like a function, the following code is invalid. ($some_var) ? echo 'true' : echo 'false'; // However, the following examples will work: ($some_var) ? print 'true' : print 'false'; // print is also a construct, but // it behaves like a function, so // it may be used in this context. echo $some_var ? 'true': 'false'; // changing the statement around ?> NOTES
Note Because this is a language construct and not a function, it cannot be called using variable functions. SEE ALSO
print(3), printf(3), flush(3), Heredoc syntax. PHP Documentation Group ECHO(3)

Check Out this Related Man Page

UNSET(3)								 1								  UNSET(3)

unset - Unset a given variable

SYNOPSIS
void unset (mixed $var, [mixed $...]) DESCRIPTION
unset(3) destroys the specified variables. The behavior of unset(3) inside of a function can vary depending on what type of variable you are attempting to destroy. If a globalized variable is unset(3) inside of a function, only the local variable is destroyed. The variable in the calling environment will retain the same value as before unset(3) was called. <?php function destroy_foo() { global $foo; unset($foo); } $foo = 'bar'; destroy_foo(); echo $foo; ?> The above example will output: bar To unset(3) a global variable inside of a function, then use the $GLOBALS array to do so: <?php function foo() { unset($GLOBALS['bar']); } $bar = "something"; foo(); ?> If a variable that is PASSED BY REFERENCE is unset(3) inside of a function, only the local variable is destroyed. The variable in the calling environment will retain the same value as before unset(3) was called. <?php function foo(&$bar) { unset($bar); $bar = "blah"; } $bar = 'something'; echo "$bar "; foo($bar); echo "$bar "; ?> The above example will output: something something If a static variable is unset(3) inside of a function, unset(3) destroys the variable only in the context of the rest of a function. Fol- lowing calls will restore the previous value of a variable. <?php function foo() { static $bar; $bar++; echo "Before unset: $bar, "; unset($bar); $bar = 23; echo "after unset: $bar "; } foo(); foo(); foo(); ?> The above example will output: Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 23 PARAMETERS
o $var - The variable to be unset. o $... - Another variable ... RETURN VALUES
No value is returned. EXAMPLES
Example #1 unset(3) example <?php // destroy a single variable unset($foo); // destroy a single element of an array unset($bar['quux']); // destroy more than one variable unset($foo1, $foo2, $foo3); ?> Example #2 Using (unset) casting (unset) casting is often confused with the unset(3) function. (unset) casting serves only as a NULL-type cast, for completeness. It does not alter the variable it's casting. <?php $name = 'Felipe'; var_dump((unset) $name); var_dump($name); ?> The above example will output: NULL string(6) "Felipe" NOTES
Note Because this is a language construct and not a function, it cannot be called using variable functions. Note It is possible to unset even object properties visible in current context. Note It is not possible to unset $this inside an object method since PHP 5. Note When using unset(3) on inaccessible object properties, the __unset() overloading method will be called, if declared. SEE ALSO
isset(3), empty(3), __unset(), array_splice(3). PHP Documentation Group UNSET(3)
Man Page