小编Tif*_*ney的帖子

为什么这不会退出while循环?

我试图在外面退出,所以我的脚本可以发布到Wordpress.com博客.但是,即使我尝试使用休息; 在if语句中,循环继续.

此函数启动脚本并基本上处理发布:

function getFlogArticle($url, $mail) {  
list($id, $title, $content, $tags) = getNewArticle();
while ($id != 0)
{
    $start = getTime(); 
    doesArticleExist($url, $id);
        if ($exist = 0)
            {
                wordpress($title, $content, $mail, $tags, $url, $id);
                break;  
                $end = getTime(); 
                echo  '<strong>Exist While</strong>: '.round($end - $start,4).' seconds<br />'; 
            }
    list($id, $title, $content, $tags) = getNewArticle();   
    echo 'I cant stop'; 
}
}
Run Code Online (Sandbox Code Playgroud)

每次doARticleExist()返回1时,此函数都会从数据库中获取文章:

function getNewArticle() {
$start = getTime(); 
global $db;
$count = $db->query("SELECT * FROM flog_articles");
$count = $count->num_rows;
$offset = mt_rand(0, …
Run Code Online (Sandbox Code Playgroud)

php while-loop

-2
推荐指数
1
解决办法
1007
查看次数

标签 统计

php ×1

while-loop ×1