Clan Adverts

PHP Web Host - Quality Web Hosting For All PHP Applications

 

Text to screen

Description: Some simple ways to output text in php
Version: 1.0
Added on: 24 February 2007
Author: unknown
Difficulty Level: Very Easy
Views: 3362
Detailed Profile

There are several ways to do this, I will list the 3 most common ones.

They are:
echo
print
die

the echo statement basically prints out anything to the screen in html format. This means whatever lies between the echo"" tags will be output to the browser as long as it is NOT a php variable or a html tag.

Example:

Code:

echo"John is a man, he is 20 years old."


This outputs
Quote:

John is a man, he is 20 years old.


With tags,
Code:

echo"John is a man, he is 20 years old".


This outputs
Quote:

John is a man, he is 20 years old.


Print works similar to echo.

Example:
Code:

print("John is a man, he is 20 years old");


Quote:

Outputs John is a man, he is 20 years old.


Die is different however, it prints text to the screen, but then it kills the PHP operation after it is done.

Example:
Code:

die("John is a man, he is 20 years old");
echo"John is a man, he is 20 years old, this is a second message";


This will only output
Quote:

John is a man, he is 20 years old
, and it will neglect the next lines of code.

Tutorials ©