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?No we can not use echo statement within echo statement. It is bad logic.
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 BlogOutput is : This is Quality Written Codes Blogecho "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 isThis 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.
- \/ => /
- \" => "
- \/\/ => //
Its output isecho "This is \"Quality Written Codes\" Blog and my name is \\ Samee Ullah Feroz \\";
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
Post a Comment
Give your reviews about this blog. Leave your comments. What do you think about this post?
Comments Guidelines:
1) I love to read comments, but please avoid spam.
2) Like this blog, share your insights, and spread the word.
3) You can use basic HTML/xHTML tags.
4) All comments are DoFollow—please use the section professionally.
5) Kindly mention your name or brand below your comment.
6) Constructive suggestions for improvement are always welcome.
Thanks for visiting Samee Articles.
========================================
Best Regards,
Samee U. Feroz