Home
Recent Articles
more...    [all articles]
Articles by Catagory
php (12 )
css (1 )
Tutorials
Related Links
<<first    <prev    1  2  (3) 4  5  6       next>     last>>
Using The Function Echo
Posted By - Ko Ko - December 28, 2006

Summary :
How to use the function echo
Printer Friendly Page
Show Myanmar Version show-myanmar-font

Using the function 'echo'

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


Posted as - [programming] [php] [code snippets]
1 comment            submit comments

End of Article No. 10 - Using the function echo
http://phpmyanmar.com/content/article/10/using-the-function-echo.html

Usage Of -single quote- And -double quote- With Strings In PHP
Posted By - Ko Ko - January 5, 2007

Summary :
How to use -single quote- and -double quote- with strings in PHP
Printer Friendly Page
Show Myanmar Version show-myanmar-font

Usage of 'single quotes' and 'double quotes' in Strings

In PHP, a string is simply a group of characters.

They can contain:-

  • letters
  • ASCII characters
  • numbers
  • other variables

When you assign a string to a variable (or) echo the string out to the browser, you have to mark the start and end of the string.

The ways of doing this are:

1. Single Quotes:
echo 'Hi there';

2. Double Quotes:
echo "Hi there";

The two methods looks similar but they are slightly different. Look at the following codes:-

<html>
<head>
<title>quotes</title>
</head>
<body>

<?php
      $name = "Sally";
      echo "My name is $name";
      echo "<br>";
      echo 'My name is $name';
?>


You will see that the output of above are different.

My name is Sally
My name is $name

In the first code line, a variable was put between a pair of double quote. Its value Sally was displayed by the browser

echo "My name is $name";  = My name is Sally

In the next code line, a variable was put between a pair of single quote. Its value Sally was not displayed by the browser.

echo 'My name is $name';   = My name is $name

Play around with single and double quotes with different strings and variables and observe the differences.


Posted as - [programming] [php] [code snippets]
0 comment            submit comments

End of Article No. 9 - Usage of -single quote- and -double quote- with strings in PHP
http://phpmyanmar.com/content/article/9/usage-of-single160quote-and-double160quote-with-strings-in-php.html

Discussion About PHP Programming
Posted By - Ko Ko - December 17, 2006

Summary :
Web Developement Seminar Organized By NaviStar Myanmar.
Printer Friendly Page
Show Myanmar Version show-myanmar-font

Discussion About PHP Programming

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


Posted as - [php] [web developement] [news]
0 comment            submit comments

End of Article No. 8 - Discussion About PHP Programming
http://phpmyanmar.com/content/article/8/discussion-about-php-programming.html

<<first    <prev    1  2  (3) 4  5  6       next>     last>>
Install Myanmar Font
  • Download the font, (zawgyi-one) here.
  • See how to install the font here.
PhpMyanmar Forum
Feedback (In Eng and Myan)