php parse string without escape


Here you will find a  free php scripts, php resources, php tutorials, web resources , jquery



<?php print "welcome to source world-php script"; ?> 


You can easily parse string in php without any escape means you can write code as like same as html.The Solution is given below.



Heredoc:parse string and variables


There is way to delimit strings is the heredoc syntax: <<<. After this operator, an identifier is provided, then a newline. The string itself follows, and then the same identifier again to close the quotation.

The closing identifier must begin in the first column of the line. Also, the identifier must follow the same naming rules as any other label in PHP: it must contain only alphanumeric characters and underscores, and must start with a non-digit character or underscore.

$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;


Nowdoc: parse only variables are not parsed

Nowdocs are to single-quoted strings what heredocs are to double-quoted strings. A nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc. The construct is ideal for embedding PHP code or other large blocks of text without the need for escaping. It shares some features in common with the SGML construct, in that it declares a block of text which is not for parsing. A nowdoc is identified with the same <<< sequence used for heredocs, but the identifier which follows is enclosed in single quotes, e.g. <<<'EOT'. All the rules for heredoc identifiers also apply to nowdoc identifiers, especially those regarding the appearance of the closing identifier.
$str = <<<'EOD'
Example of string
spanning multiple lines
using nowdoc syntax.
EOD;
Note:Unlike heredocs, nowdocs can be used in any static data context. The typical example is initializing class properties or constants. Note:When a string is specified in double quotes or with heredoc, variables are parsed within it.


You can also use this free php scripts to your free php cms software developments .This is free php scripts.This free php scripts does not take any kind of responsibilities You can always use on your own risk.You can reports bug to me for this free php scripts.  

Buy Me a Beer-If you are like this post

 If you does not have paypal account create free account create account

No comments:

Post a Comment