php中的System.out或systemout是什么?
我在探索php,发现了system.out和systemout。 php说它们是字符串,但它们的行为不像字符串。 这里有一些例子php中的System.out或systemout是什么?,php,Php,我在探索php,发现了system.out和systemout。 php说它们是字符串,但它们的行为不像字符串。 这里有一些例子 system.out.print('test'); //output test system.out.var_dump('system.out'); // output string(9) "systemout" systemout.var_dump('test'); // output str
system.out.print('test');
//output
test
system.out.var_dump('system.out');
// output
string(9) "systemout"
systemout.var_dump('test');
// output
string(4) "test"
这是语言错误吗?让我在代码中这样说:
in.fact.you.can.concat.many.undefined.constants.with.any.func.print('.');
如果启用了错误报告,php将通知您许多未定义的常量,它们将被视为字符串,因此将被视为:
'in'.'fact'.'you'.'can'.'concat'.'many'.'undefined'.'constants'.'with'.'any'.'func'.print('.');
唯一能产生所需输出的是函数调用。此函数的返回值连接到未定义常量的字符串,并且不执行任何操作 //我可以告诉您要做什么。就是将一些变量哑到控制台。
//i can tell what you are trying to do.is to dumb some vars to console.
//System.out.printLn does not exist in php
//there are other tools like firephp but this is the simplest method to log vars to console
//use the following function instead in php
function phpconsole($label='var',$x){
?>
<script type="text/javascript">
console.log('<?php echo ($label)?>');
console.log('<?php echo json_encode($x)?>');
</script>
<?php
}
//use it like this
$salary = 500;
phpconsole('salary:',$salary);
$arr = array('aaa','bbb','ccc');
phpconsole('arr:',$arr);//it will accept any datatype and dumb it to console
//php中不存在System.out.printLn
//还有其他工具,如FireHP,但这是将变量记录到控制台的最简单方法
//在php中使用以下函数
函数phpconsole($label='var',$x){
?>
控制台日志(“”);
控制台日志(“”);
@lix是的,它是php试试看..不..它在任何情况下都不是有效的php…你会收到一个很好的通知通知:使用未定义的常量系统-假定的'system'
和通知:使用未定义的常量out-假定的'out'
。我不确定你说的“它们不像字符串一样”是什么意思。实际上,你只需要使用打印(“测试”)
这看起来确实像是以某种方式进入生产的PHP代码。应该在TDWTF上结束,而不是这样。你一定是在开玩笑,他说PHP,他没有说他需要它用于网页。即使是用于网页。上面的代码是恐龙式的!无意冒犯。请遵循此链接。专业人士只需编写逻辑即可在他们所说的背后。你的评论应该以“他说PHP,…”开头。兄弟,你给出的链接非常过时(2015-2007=8),我觉得该页面上的信息不是很有用。我的观点是,我制作了PHP CLI应用程序,这在CLI中应该如何工作?顺便问一下,FireHP使用标头,这根本不会影响输出缓冲。如果有人使用此console.log方法,然后尝试标头()函数,他将得到一个致命错误,即已经发送了头。我知道这可以通过输出缓冲解决,但这将是一个黑客攻击。这意味着,这不是一个好方法,甚至不是一种方法:-)