Quantcast
Viewing all articles
Browse latest Browse all 15

Dealing with Quotation mark in PHP

Image may be NSFW.
Clik here to view.
php

You may have seen use of double quotation marks and single quotation marks in PHP. In this tutorial we will see how to deal with quotations marks in PHP. When and how to use single quotation mark and double quotation marks in PHP.


Rule 1: Cannot use double quotation mark within a double quotation mark
And similarly cannot use single quotation mark within a single quotation mark
Following is a wrong way to deal in PHP. It will produce some error.

<?php
	echo "<font color="red">Welcome to 9zap.com";
?>

Rule 2: Use single quotation mark within a double quotation mark
Similarly you can use double quotation mark inside a single quotation mark.
Below is the correct way to write above php code.

<?php
	echo "<font color='red'>Welcome to 9zap.com";
?>

You can also use back slash to use same type of quotation mark in PHP.
Example:

<?php
echo '<font color=\'red\'>Welcome to 9zap.com';
?>

Viewing all articles
Browse latest Browse all 15

Trending Articles