Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
133 views
in Technique[技术] by (71.8m points)

php - 如何用PHP写入控制台?(How can I write to the console in PHP?)

Is it possible write a string or log into the console?

(是否可以在控制台中写入字符串或日志?)

What I mean (我的意思是说)

Just like in JSP, if we print something like system.out.println("some") , it will be there at the console, not at a page.

(就像在JSP中一样,如果我们打印类似system.out.println("some") ,它将在控制台上,而不是在页面上。)

  ask by Labeeb Panampullan translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Or you use the trick from PHP Debug to console .

(或者您使用PHP Debug中的技巧来控制 。)

First you need a little PHP helper function

(首先,您需要一个小的PHP帮助函数)

function debug_to_console($data) {
    $output = $data;
    if (is_array($output))
        $output = implode(',', $output);

    echo "<script>console.log('Debug Objects: " . $output . "' );</script>";
}

Then you can use it like this:

(然后你可以像这样使用它:)

debug_to_console("Test");

This will create an output like this:

(这将创建一个这样的输出:)

Debug Objects: Test

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...