草庐IT

using_view_debugger

全部标签

php - 如何从 View 中查询数据库 - CodeIgniter

我有在Controller中运行的查询:$data['query']=$this->Member->select_sql($id);$this->load->view('myform');然后在View中输出数据:foreach($query->result()as$row):echo$row->post_title;echo$row->post_user_id;endforeach;所以这会输出一个用户发布的帖子列表。现在我想再运行一个查询,针对每个帖子循环遍历我的用户表并在每个帖子旁边输出用户信息。(此时我不想从View中选择数据或在MySQL中连接这两个表)有什么想法吗?

php - .htaccess 重写规则 : two domains using same server and directory

作为背景知识,我们有两个域:mydomain.commydomain.czmydomain.cz指向mydomain.com的服务器并使用相同的目录。我们在.htaccess(两个域共享)中有一个RewriteRule,如下所示:RewriteRule^([0-9]+)/?$project.php?id=$1[NC,L]#HandleprojectrequestsRewriteRule^([0-9]+)/?$project_cz.php?id=$1[NC,L]#Handleprojectrequests此RewriteRule在使用来自mydomain.com/project.php?

php - gmmktime() : You should be using the time() function instead

出现以下错误的原因是什么?如何解决问题?gmmktime():Youshouldbeusingthetime()functioninstead第90行的问题:89date_default_timezone_set("GMT");90$time=gmmktime(); 最佳答案 gmmktime()内部使用mktime(),在不带参数调用时抛出E_STRICT通知,因此使用time()代替功能。 关于php-gmmktime():Youshouldbeusingthetime()funct

php - Yii 框架从 Controller 传递变量到 View

要将变量传递给我使用的登录View:$this->render('login',array('model'=>$model));但我还需要在模板部分footer.php中访问这个变量:我试试这个:$this->render('footer',array('model'=>$model));但是当我在footer.php中尝试访问变量时,我得到错误“undefinedvariable”怎么了? 最佳答案 例如,您可以使用Controller类在View模板中传递变量Controller:SomeControllerextendsCon

php - YII 2.0.3 View 不呈现。它只是一片空白。调用索引时仅显示 1

我正在经历制作自定义应用程序Web应用程序开发的Yii2章节MarkSafronov和JeffreyWinesett使用Yii2和PHP。但是,我被困得很糟糕!当我尝试(在localhostwamp服务器上运行高级模板)时,View不呈现...http://localhost/furni/frontend/web/index.php?r=customers它触发的Action是..classCustomersControllerextendsController{publicfunctionactionIndex(){$records=$this->findRecordsByQuery

php 容器类 : why does everyone use the more complicated method?

当我找到php脚本或查看php框架时,我看到一个“注册表类”或“容器类”,它们通常使用__get魔法方法保存变量或其他对象。这是我的意思的一个过于简单的例子:示例1:classcontainer{private$objects;publicfunction__get($class){if(isset($this->objects[$class])){return$this->objects[$class];}return$this->objects[$class]=new$class();}}上面的例子在创建类时会有更多的功能,而不是仅仅调用它,但对于我的例子来说它应该足够了。“示例1

php - fatal error : Cannot use assign-op operators with overloaded objects nor string offsets

这个问题在这里已经有了答案:php-addstringatoffset?(2个答案)关闭3年前。出现以下错误Fatalerror:Cannotuseassign-opoperatorswithoverloadedobjectsnorstringoffsetsinapp/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Price.phponline126尝试在产品网格中过滤产品时在我的服务器上。我根本没有更改任何核心文件,但它显示了核心文件第126行。我用谷歌搜索了这个问题,没有正确的结果。有人遇到这个问题并解决了吗?我不

PHP - 如何解决错误 "using $this when not in object context"?

我有这个特质类:traitExample{protected$var;privatestaticfunctionprintSomething(){print$var;}privatestaticfunctiondoSomething(){//dosomethingwith$var}}这个类:classNormalClass{useExample;publicfunctionotherFunction(){$this->setVar($string);}publicfunctionsetVar($string){$this->var=$string;}}但是我收到了这个错误:fatale

php - 如何从 PHP Laravel 5 中的 View 访问 cookie

我可以在Controller中访问c​​ookie然后将它传递给View//HomeController.phppublicfunctionindex(Request$request){$name=Cookie::get('name');returnview('index',['name'=>$name]);}但我想编写一个小控件(小部件),它可以从cookie中获取数据而无需担心父Controller。例如,页眉、页脚小部件可以在主页面Controller不知道需要哪些数据的情况下获取自己的数据。我可以使用ViewComposer从数据库中查询数据。但是,如何从请求cookie中的V

php - MVC : Why bother "sending" data to the View

我是MVC的新手,所以我一直在网上搜索以尝试构建我自己的框架以真正了解整个概念的工作原理。无论如何,几乎所有处理MVC的教程似乎总是将需要在View中显示的数据分配给然后在View中使用的中间变量。我的问题是,为什么要费心去做那个额外的步骤?大多数MVC实现最终都将View包含在Controller中...所以如果是这样,为什么要浪费时间/内存/cpu周期来创建一个中间变量/数组,然后在View结束时将其传递给View最后包含在Controller中。直接在View中直接使用Controller变量不是更有意义吗?下面是一个代码示例,希望能阐明我的意思:classNews_Contro