Total members 11895 |It is currently Fri Dec 27, 2024 6:10 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





As we saw in previews examples echo command is used for displaying the strings .you will use echo command many times in your web application .

Example of using echo command

Code:
<?
   
echo "<b>My name is tom</b>";
?>


or using a variable
Code:
<?
   $mystring
="My name is tom";
   echo
"<b> $mystring </b>";
?>


the output of both codes is :
My name is tom


Dealing with Quotes!

Guidelines :
* Don't use quotes inside your string
* Escape your quotes that are within the string with a backslash. To escape a quote just place a backslash directly before the quotation mark, i.e. \"
* Use single quotes (apostrophes) for quotes inside your string.

Here codes example :
Code:
<?php
// This won't work because of the quotes around myh5!
echo "<h5 class="myh5">I am 22 years old !</h5>"; 

// Now  work because we escaped the quotes!
echo "<h5 class=\"myh5\">I am 22 years old !</h5>"; 

// work , because we used an apostrophe '
echo "<h5 class='myh5'>I am 22 years old</h5>"; 
?>


Join variables and strings

you can join variables and text string using dot (.) .By this way you will save large number of echo command statements .

example

Code:
<?php
  $mystring ="<br/>Hi . my name is : ";
  echo $mystring." tom";
  echo $mystring." john";
?>


The output of this code is :
Code:
Hi . my name is :  tom
Hi . my name is :  john




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : PHP echo command
 echo command to output HTML     -  
 Echo multiline string     -  
 Difference between PHP echo() and PHP print()?     -  
 echo client using Sockets     -  
 BETWEEN SQL COMMAND     -  
 Calling the man Command     -  
 SQL LOCATE command     -  
 SQL LIKE query Command     -  
 SQL ALTER Command     -  
 SQL GROUP BY Command     -  



Topic Tags

PHP Basics






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com