php中的System.out或systemout是什么?

时间:2013-03-24 20:12:47

标签: 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 

string(4) "test"

这是语言错误吗?

2 个答案:

答案 0 :(得分:5)

让我在代码中说出这个:

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('.');

唯一产生所​​需输出的是函数调用。此函数的返回值连接到未定义常量的字符串,不执行任何操作。

答案 1 :(得分:-1)

//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