<?php
error_reporting(E_WARNING);
//just put above line , don't ask anything
//concentrate on usage of echo
echo "Hello World ";
echo "<br>=============================<br>";
echo "This spans
multiple lines. The new lines will be
output as well";
echo "<br>=============================<br>";
echo "Escaping characters is \"Like this\".";
echo "<br>=============================<br>";
$foo = "foobar";
$bar = "barbaz";
echo "foo is $foo";//foo is foobar
echo "<br>";
echo "bar is $bar";//bar is barbaz
echo "<br>=============================<br>";
// You can also use arrays
$bar1 = array("value" => "foo");
echo "this is {$bar1['value']} !";
// this is foo ;
echo "<br>=============================<br>";
// Using single quotes will
// print the variable name,
// not the value
echo 'foo is $foo'; // foo is $foo
echo "<br>=============================<br>";
// If you are not using any
// other characters, you can
// just echo variables echo $foo; // foobar
echo "<br>";
echo $foo.$bar; // foobarbarbaz
echo "<br>=============================<br>";
// Some people prefer passing
// multiple parameters
// over concatenation.
//with multiple parameters>
echo 'This ','string ','was ','made.';
echo "<br>";
//with concatenation
echo 'This '.'string '.'was '.'made.';
echo "<br>=============================<br>";
$foo = <<<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 white space!
END;
echo $foo;
echo "<br>=============================<br>";
?> </body>
</html>
Open a browser and type -
http://localhost/echo_example.php - in the address bar and you will see
as in figure.1
figure.1
Study 'code.1' line by line and compare with the result of the
monitor screen.
When you see a bunch of codes that is working properly. hold on to it. Save
it somewhere. Then make a copy and play around with the code and see what
happened.
Don't try and change in a lot of places at once otherwise you won't know
where you go wrong. See what type of error message PHP post back to you.
This is the best way to learn by yourself and it was and still is the way I
learn PHP.
<?php
error_reporting(E_WARNING);
//just put above line , don't ask anything
//concentrate on usage of echo
echo "Hello World ";
echo "<br>=============================<br>";
echo "This spans
multiple lines. The new lines will be
output as well";
echo "<br>=============================<br>";
echo "Escaping characters is \"Like this\".";
echo "<br>=============================<br>";
$foo = "foobar";
$bar = "barbaz";
echo "foo is $foo";//foo is foobar
echo "<br>";
echo "bar is $bar";//bar is barbaz
echo "<br>=============================<br>";
// You can also use arrays
$bar1 = array("value" => "foo");
echo "this is {$bar1['value']} !";
// this is foo ;
echo "<br>=============================<br>";
// Using single quotes will
// print the variable name,
// not the value
echo 'foo is $foo'; // foo is $foo
echo "<br>=============================<br>";
// If you are not using any
// other characters, you can
// just echo variables echo $foo; // foobar
echo "<br>";
echo $foo.$bar; // foobarbarbaz
echo "<br>=============================<br>";
// Some people prefer passing
// multiple parameters
// over concatenation.
//with multiple parameters>
echo 'This ','string ','was ','made.';
echo "<br>";
//with concatenation
echo 'This '.'string '.'was '.'made.';
echo "<br>=============================<br>";
$foo = <<<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 white space!
END;
echo $foo;
echo "<br>=============================<br>";
?> </body>
</html>
All photograph,logos, articles, comments and trademarks -- etc in this site are property of their respective owners.All the rest (c) 2006 by PhpMyanmar.com.