The only characters that need to be escaped to be echo'd to the browser are " and ' depending on your syntax.
example
Code: Select all
$string = "John said, \"PHP Rocks!\", in a whisper.";
// OR
$string = 'John said, \'PHP ROCKS!\', in a whisper.';
The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.
If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is < and > is > and & is &. However the php function htmlentities() does this for you if you'd prefer to do it that way.mp;quote;, in a whisper.";
// OR
$string = 'John said, \'PHP ROCKS!\', in a whisper.';
The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.
If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is < and > is > and & is &. However the php function htmlentities() does this for you if you'd prefer to do p function htmlentities() does this for you if you'd prefer to do it that way. the browser are " and ' depending on your syntax.
example
Code: Select all
$string = "John said, \"PHP Rocks!\", in a whisper.";
// OR
$string = 'John said, \'PHP ROCKS!\', in a whisper.';
The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.
If you want to print out your HTML to the browser, = "John said, \"PHP Rocks!\", in a whisper."e;;
// OR
$string = 'John said, \'PHP ROCKS!\', in a whisper.';
The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.
If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is < ato the browser are " and ' depending on your syntax.
example
Code: Select all
$string = "John said, \"PHP Rocks!\", in a whisper.";
// OR
$string = 'John said, \'PHP ROCKS!\', in a whisper.';
The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.
If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is < and > is > and & is &. However the php function htmlentities() does this for you if you'd prefer to do it that way.s enclosed in, escape it.
If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is < and > is > and & is &. However the php function htmlentities() does this for you if you'd prefer to do it that way. that your value is enclosed in, escape it.
If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is < and > is > and & is &. However the php function htmlentities() does this for you if you'd prefer to do it that way.cf8c0f8669]
$string = "John said, \"PHP Rocks!\", in a whisper.";
// OR
$string = 'John said, \'PHP ROCKS!\', in a whisper.';
The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.
If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is <
$string = "John said, \"PHP Rocks!\", in a whisper.";
// OR
$string = 'John said, \'PHP ROCKS!\', in a whisper.';
The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.
If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is < and > is > and & is &. However the php function htmlentities() does this for you if you'd prefer to do it that way.