Subscribe To Our Newsletter

Sign Up Now To Get Free Coupon Codes, Event Coupon Codes Updates, Offers Updates. It's 100% Free!

We Hate Spam! Really, It's terrible and we never do it.

Echo Rules / Problems in PHP Language

Echo is used to show output results in PHP. But sometimes you get confuse for solving simple problems. like

How to add Conditional Statement within echo statement?
 It is wrong to use if conditional statement within echo statement. You should use ternary operator within echo statement. like
 echo '<li' . ($sel_subject == $subject['id']) ? 'class="selected"' : '' . '>';  

Can we use echo statement within echo statement?
No we can not use echo statement within echo statement. It is bad logic. 

Can we use echo with double or single quotes?
Yes; you can use  echo with double and single quotes like

 echo 'This is Quality Written Codes Blog';  
Output is : This is Quality Written Codes Blog

 echo "This is Quality Written Codes Blog";  
Output is : This is Quality Written Codes Blog

What is concatenation in echo statement? 
Concatenation is sued to connect two quotes blocks. like 

 echo "My Blog Name is " . "Quality Written Codes";  

" . " dot is used to add concatenation.

How to use backslash within echo?
There are two ways to use backslash within echo tag.

You can use single quote if you want to use backslash; like it

 echo 'This is Quality Written Codes Blog And My Name is \ Samee Ullah Feroz \';  
Its output is
This is Quality Written Codes Blog and My Name is \ Samee Ullah Feroz \

If you use double quotes for echo statement. then you need to remember this solutions.
  1. \/ => /
  2. \" => "
  3. \/\/ => //
 echo "This is \"Quality Written Codes\" Blog and my name is \\ Samee Ullah Feroz \\";  
Its output is 
This is Quality Written Codes Blog and My Name is \ Samee Ullah Feroz \

How to use Variables within and with echo?
You can use different methods for it. like 

 $blog = "Quality Written Codes";  
 echo "$blog";  
 echo '{$blog}'  
 echo $blog;  

Read More about it in our previous post : Display of Variables
Share this article :

Post a Comment

Give your reviews about this blog. Leave your comments. what do you think about this post?

Comments Description is given below:
1) I love to read comments, but do not spam.
2) Like this blog and also tweet its posts.
3) You can use some xHTML tags.
4) All Comments are Do Follow, Please try to use blog professionally.
5) Mention Your Name below the comment.
6) You can also suggest for improvement.
7) Do not forget to subscribe Samee Articles blog.

---------------------------------------
Thanks for visiting QWC.Me.
==========================================
For free guidelines contact me on SEO Expert | Samee Ullah Feroz is online there.
==========================================
Best Regards

 
Support : | Internet Marketing Specialist And Business Developer
Copyright © 2013-2016. Samee Articles - All Rights Reserved
Proudly powered by Blogger