Home
Recent Articles
Php (By Category)
Misc (1)
News (1)
String (1)
Resources (By Category)
Web (1)
Tutorials
Links

Useful PHP Links






    < Previous 4 Articles       Next 4 Articles >    
Show Myanmar Version show-myanmar-fontPrinter Friendly Page

Using the function 'echo'
By - Ko Ko - December 28, 2006 - 4:18 am

No matter how complicated a program is, finally it will return an answer.

Then the programmer usually do the followings-

  • Save the answer to a file.
  • Put it on the monitor screen for the user to see.
  • Output it to a speaker or earphone for the user to hear.

Let us confine yourself to putting something on the screen for the user to see.

PHP use the function echo to make users see things on the screen.

There are several other functions either than echo but we will study only echo here.

The easiest way to understand something is to study a working example

Copy and paste the following codes to a notepad and save it as a file name echo_example.php in the easyphp 'www' folder.

code.1
<html>
<head>
<title>Using echo function</title>
</head>
</body>

<?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.

Download echo_example.zip


(End of Article)

url = http://phpmyanmar.com/index.php/pphp/article/169
Get results from [ 18 ] search engines in 'one click'
 
Show Myanmar Version show-myanmar-fontPrinter Friendly Page

Discussion About PHP Programming
By - Ko Ko - December 17, 2006 - 8:25 pm

A discussion about PHP programming was made at a seminar held at MICT Park (an IT park) on 18th November 2006, 1400hr.

U Minn Myat Soe from NaviStar Myanmar gave an opening speech

Contributors

This seminar was organized by NaviStar Myanmar (an internet hosting company). The subject on "PHP Programming" was discussed by U Htay Win (Total Myanmar) and U Win Htein Win (Gusto Software) discussed about ASP .NET 2.0.

Attendees

About 170 interested people attended the seminar and many interesting question were asked at the end of the discussions, especially about PHP.

Organizer - NaviStar Myanmar (Professional Web Hosting & Design)

ppt slides on discussion of Php


(End of Article)

url = http://phpmyanmar.com/index.php/pphp/article/168
Get results from [ 18 ] search engines in 'one click'
 
Show Myanmar Version show-myanmar-fontPrinter Friendly Page

How to get information of the Php installed on your server.
By - Ko Ko - May 19, 2006 - 12:30 pm

Just by writing one short line of php code, you can extract 4 or 5 pages of information about the php installed on your server.

Write the following codes in a notepad and save as "phpinfo.php" in your "www" folder.

<html>
      <head>
          <title>PhpInfo</title>
      </head>
      <body>
              <?php
                   phpinfo();
              ?>

       </body>
</html>

The word "phpinfo()" is one of the Php functions called "Php Built in Function".

Type http://localhost/phpinfo.php in your browser and click enter. The following will appears.


(End of Article)

url = http://phpmyanmar.com/index.php/pphp/article/55
Get results from [ 18 ] search engines in 'one click'
 
Show Myanmar Version show-myanmar-fontPrinter Friendly Page

Your First Php Program
By - Ko Ko - May 19, 2006 - 12:30 pm

Before writing our very first Php program a short explanation about Php tags will be needed.

Php code can be freely mixed with html codes.

When html code ends and php code started you have to type in the "php start tag".

Also when the php code ends and html code started again, the "php end tag" have to be type in again.

Various pairs of "php start tag" and "php end tag" are shown below:-

PHP Start and End Tags

Tag Style

Start Tag

End Tag
Standard tags <?php ?>
Short tags <? ?>
ASP tags <% %>
Script tags <script language="php"> </script>

See below how these 4 pairs of Php Tag are used:-

<?php
      put your php code here;
?>
<?
      put your php code here;
?>
<%
       put your php code here;
%>
<script language="php">
       put your php code here;
</script


Now lets write our first php program.

Open MS Notepad and type the code shown below. Observe carefully how the start and end tags were used.

<html>
    <head>
        <title>hello</title>
    </head>
    <body>
        <?php
            echo "Hello World!";
        ?>

    </body>
</html>


Save as "hello.php" in folder "www" shown below.



Now close the notepad and open the browser.

In the address box type in http://localhost/hello.php and click enter.

If you have done everything properly, you will see "Hello World!" as shown below.

Congratulation, you have written your first php program successfully.


(End of Article)

url = http://phpmyanmar.com/index.php/pphp/article/54
    < Previous 4 Articles       Next 4 Articles >    
Install Myanmar Font
  • Download the font, (zawgyi-one) here.
  • See how to install the font here.
Forums

PhpMyanmar Forum

mmGeeks.org Forum

Feedback (In Eng and Myan )
 
visited