草庐IT

if_exists

全部标签

php - Yii2错误: The view file does not exist

我已经使用Yii2几个星期了,并且掌握了它的窍门。然而,今天,由于我不知道的原因,Yii将我路由到错误的页面,导致错误,因为没有找到网页:URL:http://localhost/web/index.php?r=site/indexError:InvalidParameter–yii\base\InvalidParamExceptionTheviewfiledoesnotexist:C:\xampp\htdocs\views\site\index.php但是,自从我开始使用Yii2以来,我已经能够使用http://localhost/web/index.php?r=paramA/par

php - file_exists 相对路径不起作用

file_exists不工作..也尝试过realpath..同样的问题首先检查文件是否存在..file_exists返回false但文件仍然被加载chdir(__DIR__.'/../..');$file='frontend.php';echo"$file\n";if(file_exists($file)){echo"Filefound\n";}else{echo"Filenotfound\n";}require$file;输出frontend.phpFilenotfoundContentsoffrontend.php 最佳答案 作

php - laravel @if 语句显示在 View 中

我是第一次学习Laravel,今天才开始。在LAMPP-Ubuntu上通过Composer安装全新的Laravel。在我的终端中运行sudo/opt/lampplamppstart后,我打开Chrome并导航到localhost/MYAPP/resources/views/welcome.blade.php。This是呈现的View。“@”语句(我假设特定于Laravel的Controller)呈现在浏览器的屏幕上,我无法弄清楚为什么会这样。感谢任何/所有见解!编辑:这里是我的welcome.blade.php文件:getLocale()}}">Laravelhtml,body{bac

PHP/PostgreSQL : check if a prepared statement already exists

我将准备好的语句创建为:pg_prepare('stm_name','SELECT...');今天,我在两次声明同名的准备好的语句时遇到了一个问题(错误地调用了两次函数):Warning:pg_prepare()[function.pg-prepare]:Queryfailed:ERROR:preparedstatement"insert_av"alreadyexistsinxxxonline221所以,正如问题标题,有一种方法可以检查是否已经存在具有相同标签的准备语句,如果存在,则覆盖它?我知道这个错误是我的错误,只需在我的代码开头声明准备好的语句即可解决,但我想知道是否有解决方案可

PHP fatal error : Allowed memory size - on a non-existent line

我有时会在我的生产服务器中看到这个错误(我的意思是,这似乎是随机的,因为我的网站流量不错,到目前为止它只发生了5次):[21-Feb-201223:43:19UTC]PHPFatalerror:Allowedmemorysizeof67108864bytesexhausted(triedtoallocate261900bytes)in/home/xxxxx/xxxxx/xxx.phponline1811有趣的是,文件只有798行,而这在我之前从未发生过。是的,这可能与我最近对脚本所做的更改有关,但这个错误对我来说根本没有意义。请记住,我知道“Allowedmemorysizeexhau

php - 为什么我们需要 function_exists?

为什么我们需要检查用户定义函数的function_exists?内部或核心PHP函数看起来没问题,但如果用户知道并自己定义了一个函数,那么为什么还需要检查它是否存在?下面是自定义的用户定义函数if(!function_exists('bia_register_menu')){functionbia_register_menu(){register_nav_menu('primary-menu',__('PrimaryMenu'));}add_action('init','bia_register_menu');}谢谢 最佳答案 确保

php - 试图避免 "spaghetti code",为什么多个 if-else 不好?

我刚刚在读top100signsofspaghetticode我遇到了数字4,它简单地说明:if($status=="awake"){$actitivity="Writingspaghetticode";}elseif($healthstatus=="OK"){$activity="Sleep";}else{print"CALL911IMMEDIATELY!";}我在otherspaghettidiscussions中看到过这种多重if-else模式.我有点困惑为什么会这样,即使它适用于这个例子。上面的例子不好是因为第一个变量是activity,它表示编码器需要一些sleep,所以这是

php - 处理您的请求时出错 : SQLSTATE[42S01]: Base table or view already exists: in magento 1. 9

我已经在我的本地服务器上安装了magento1.9CE,它工作正常。突然它停止工作并显示错误TherehasbeenanErrorprocessingyourrequest.当我从报告文件夹中检查错误报告时,我得到了类似这样的日志a:5:{i:0;s:219:"Errorinfile:"C:\wamp\www\anzonline\app\code\core\Mage\XmlConnect\sql\xmlconnect_setup\upgrade-1.6.0.0-1.6.0.0.1.php"-SQLSTATE[42S01]:Basetableorviewalreadyexists:105

php - "and"关键字和PHP中的if(TRUE)是一样的吗

在Laravel5的模型类中,我遇到了以下代码,我不确定它是什么意思。$query=User::query();\Request::input('name')and$query->where('name','like','%'.\Request::input('name').'%');\Request::input('email')and$query->where('email','like','%'.\Request::input('email').'%');return$query->paginate(15);和下面的代码一样吗?if(\Request::input('name')

PHP:在同一个if语句中分配变量并对其进行测试?

我想这样做:if($field=myFunction($node,'field')&&$field['value']){//dosomethingwith$field}PHPStorm警告$field在&&之后未定义,即使它刚刚被设置。这只是PHPStorm不稳定,还是因为某些原因这实际上不应该起作用? 最佳答案 这是运算符优先级。看看http://docs.php.net/manual/en/language.operators.precedence.php应该是:if(($field=myFunction($node,'fiel