如何停止或暂停 php 执行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5505846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to stop or pause php execution?
提问by chobo
I want to do some basic debugging with print_r.
我想用print_r 做一些基本的调试。
When PHP hits that line I want it to stop or end whatever people usually do, so I can see the output.
当 PHP 到达该行时,我希望它停止或结束人们通常所做的任何事情,以便我可以看到输出。
采纳答案by meouw
// if you want a one liner:
die(print_r($stuff, true ));
You'd really enjoy a proper debuggerthough
你会很享受适当的调试器,虽然
回答by Frosty Z
回答by Sameer Parwani
Here:
这里:
print_r($whatever);
exit();
回答by linus72982
die("Script Stopped");
This will end execution of code and echo the message you put between the quotations - this can be a string or an integer you need to debug, I use it often when debugging. Half-split works well, put var_dumps halfway through your code, put a die at the end, find which half is going wrong, split that in half, etc, until you get to a point that you can logically guess where the error is and start debugging the syntax/etc.
这将结束代码的执行并回显您放在引号之间的消息 - 这可以是您需要调试的字符串或整数,我在调试时经常使用它。半分割效果很好,将 var_dumps 放在代码的一半,最后放一个骰子,找出哪一半出了问题,将其分成两半,等等,直到你达到可以从逻辑上猜测错误所在的地步,开始调试语法/等。
回答by user1483887
I like to keep it in the family, one file....
我喜欢把它放在家里,一个文件......
if (@$_GET['thispic']){
dizzy($_GET['thispic']);
exit;
}
function dizzy($thispic){
$PSize = filesize($thispic);
$mysqlPicture = fread(fopen($thispic, "r"), $PSize) ;
///add file type checking here
Header( "Content-type: image/jpg") ;
echo $mysqlPicture;
}
$Picture = "images/brand.jpg";
echo "<img src = \"test.php?thispic=$Picture \" height = \"300\">";
I use similar script for thumbnails from a database. to avoid the base64 decoding thus saving load time.
我对数据库中的缩略图使用类似的脚本。避免 base64 解码从而节省加载时间。
contact: [email protected]
联系方式:[email protected]