Programming Tutorials

(追記) (追記ここまで)

Here-docs (<<<) in PHP

By: Emiley J. in PHP Tutorials on 2008年11月22日 [フレーム]

Here-docs enable you to embed large pieces of text in your scripts, which may include lots of double quotes and single quotes, without having to constantly escape them.

The following is an example of a here-doc:

<<<THE_END

PHP stands for "PHP: Hypertext Preprocessor".

The acronym "PHP" is therefore, usually referred to as a recursive acronym because the long form contains the acronym itself.

As this text is being written in a here-doc there is no need to escape the double quotes.

THE_END

The strings starts with <<<, followed by a string that you know doesn't appear in your text. It is terminated by writing that string at the beginning of a line, followed by an optional semicolon (;), and then a required newline (\n). Escaping and variable substitution in here-docs is identical to double-quoted strings except that you are not required to escape double quotes.




(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /