当您可以使用<<<和结束分隔符? [英] What is it called when you can fill a string with <<< and an end-delimiter?

查看:172
本文介绍了当您可以使用<<<和结束分隔符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在C + +和PHP中,你可以填充一个字符串或文件与硬编码的文本。如果我记得正确,这是应该看起来:

I know in C++ and in PHP you can fill a string or a file with hard-coded text. If I remember correctly this is how it is supposed to look:

var <<< DELIMITER
   Menu for program X
   1.Add two numbers
   2.Substract two numbers
   3.Multiply two numbers
   Please pick an option from (0-3);
DELIMITER

这可用于菜单或文本,标题。但不必执行:

This can be used for menus or text that remains the same no matter what like a header. But without having to do:

foobar << "Menu for program X" << endl << "1.Add two numbers" << endl << "2.Substract two numbers"


推荐答案

a PHP href =http://php.net/heredoc =nofollow> HEREDOC 语法:

It's called the HEREDOC syntax in PHP:

<?php

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

?>

这篇关于当您可以使用&lt;&lt;&lt;和结束分隔符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆