循环问题基本PHP-我需要什么样的循环



我有一个函数,所以如果is_page(280(为true,我想用get_template_part('nav'(;调用一个php文件。我可以用if-else循环来做。但是,在得到php文件后,我的主php文件继续读取以下行,如html等。我不想要它。如果is_page(280(为true,我想停止读取以下行。我也想为不同的值开发相同的循环。例如,如果is_page(999(为true,而is_paage(280(为false,那么现在,调用不同的php文件并停止读取主php中的以下行。如果关于is_page函数的所有条件都为false,那么现在阅读main php中的以下行。

我知道这是基本的,我等待你的帮助。

如果需要,可以使用变量停止脚本。

$stop_script = false;
if(is_page(280)===true){
... include file;
$stop_script=true;
}
else if(is_page(999)===true){
... include file;
$stop_script=true;
}
if($stop_script === true) die; //stop the script
//rest of php

或者,如果加载了模板,则仅为die

if(is_page(280)===true){
... include file;
die;
}
else if(is_page(999)===true){
... include file;
die;
}

最新更新