heredoc

PHP syntax error T_ENCAPSED_AND_WHITESPACE

孤者浪人 提交于 2019-12-02 02:43:18
i'm starting to work with php basics and i have some problem understanding how mix code with strings. I found a great and useful style to print string blocks but i don't know the name and i'm not able to find examples. the code below return me the error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /web/htdocs/food/user/index.php on line 120 <?php $html_str = <<<STR <li><img alt="hello" src="$path_images/pencil.png"/><a title="hello" href="$path_pages/$page/action">Details</a></li> STR; print $html_str; ?> can someone help

PHP syntax error T_ENCAPSED_AND_WHITESPACE

别说谁变了你拦得住时间么 提交于 2019-12-02 01:59:30
问题 i'm starting to work with php basics and i have some problem understanding how mix code with strings. I found a great and useful style to print string blocks but i don't know the name and i'm not able to find examples. the code below return me the error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /web/htdocs/food/user/index.php on line 120 <?php $html_str = <<<STR <li><img alt="hello" src="$path_images/pencil.png"/><a

What does <<DESC mean in ruby?

做~自己de王妃 提交于 2019-12-02 01:03:43
I am learning Ruby, and in the book I use, there is an example code like this #... restaurant = Restaurant.new restaurant.name = "Mediterrano" restaurant.description = <<DESC One of the best Italian restaurants in the Kings Cross area, Mediterraneo will never leave you disappointed DESC #... Can someone explain to me what <<DESC means in the above example? How does it differ from the common string double quote? It is used to create multiline strings. Basically, '<< DESC' tells ruby to consider everything that follows until the next 'DESC' keyword. 'DESC' is not mandatory, as it can be replaced

Help me understand this Perl statement with <<'ESQ'

别说谁变了你拦得住时间么 提交于 2019-12-01 23:19:04
substr($obj_strptime,index($strptime,"sub")+6,0) = <<'ESQ'; shift; # package .... .... ESQ What is this ESQ and what is it doing here? Please help me understand these statements. Quentin It marks the end of a here-doc section . EOF is more traditional than ESQ though. This construct is known as a here-doc (because you're getting standard input from a document here rather than an external document on the file system somewhere). It basically reads everything from the next line up to but excluding an end marker line, and uses that as standard input to the program or command that you're running.

How to display the value of an array element or object property in PHP Heredoc syntax

倖福魔咒の 提交于 2019-12-01 18:44:52
问题 I'm having trouble displaying an array value inside a heredoc input field. Here's a snippet of code: class Snippet{ protected $_user; protected $_class; protected $_messages; public function __construct(){ $this->_user = $this->_class = NULL; $this->createUser(); } public function createUser(){ $keys = array('user_login','user_email'); $this->_user = $this->_class = array_fill_keys($keys, ''); } public function userErrors(){ //by default give the login field autofocus $_class['user_login'] =

Heredoc strings in C#

ⅰ亾dé卋堺 提交于 2019-12-01 15:34:54
Is there a heredoc notation for strings in C#, preferably one where I don't have to escape anything (including double quotes, which are a quirk in verbatim strings)? As others have said, there isn't. Personally I would avoid creating them in the first place though - I would use an embedded resource instead. They're pretty easy to work with, and if you have a utility method to load a named embedded resource from the calling assembly as a string (probably assuming UTF-8 encoding) it means that: If your embedded document is something like SQL, XSLT, HTML etc you'll get syntax highlighting because

Heredoc strings in C#

夙愿已清 提交于 2019-12-01 13:40:26
问题 Is there a heredoc notation for strings in C#, preferably one where I don't have to escape anything (including double quotes, which are a quirk in verbatim strings)? 回答1: As others have said, there isn't. Personally I would avoid creating them in the first place though - I would use an embedded resource instead. They're pretty easy to work with, and if you have a utility method to load a named embedded resource from the calling assembly as a string (probably assuming UTF-8 encoding) it means

Proper way to access a static variable inside a string with a heredoc syntax?

主宰稳场 提交于 2019-12-01 00:59:47
Lets say I have a static variable called $_staticVar in my class which I am trying to access like this. The variable has a member aString which has the string value of "my static variable" echo <<<eos <br/>This is the content of my static variable, self::$_staticVar->$aString which is not getting accessed properly in heredoc syntax. <br/> eos; Output: Notice: Undefined variable: _staticVar in /path/to/file.php on line some_line_number <br/>This is the content of my static variable, self::->my static variable, which is not getting accessed properly in heredoc syntax.<br/> The PHP docs for

What's the difference between “here string” and echo + pipe

大憨熊 提交于 2019-11-30 19:41:28
Wondering what is the right use of here-string (here-document) and pipe. For example, a='a,b,c,d' echo $a | IFS=',' read -ra x IFS=',' read -ra x <<< $a Both methods work. Then what would be the difference between the two functionality? Another problem that I have about "read" is that: IFS=',' read x1 x2 x3 x4 <<< $a does not work, x1 is valued as "a b c d", and x2, x3, x4 has no value but if: IFS=',' read x1 x2 x3 x4 <<< "$a" I can get x1=a, x2=b, x3=c, x4=d Everything is okay! Can anyone explain this? Thanks in advance In the pipeline, two new processes are created: one for a shell to

Proper way to access a static variable inside a string with a heredoc syntax?

折月煮酒 提交于 2019-11-30 19:09:03
问题 Lets say I have a static variable called $_staticVar in my class which I am trying to access like this. The variable has a member aString which has the string value of "my static variable" echo <<<eos <br/>This is the content of my static variable, self::$_staticVar->$aString which is not getting accessed properly in heredoc syntax. <br/> eos; Output: Notice: Undefined variable: _staticVar in /path/to/file.php on line some_line_number <br/>This is the content of my static variable, self::->my