草庐IT

THIS_FILE

全部标签

php - file_get_contents() 没有响应 - php

我正在尝试调用一个基本如下所示的网络服务:http://10.10.10.10:8080/gw/someAction?amount=10&description='Somedescription'我就是这样称呼这个网络服务的:$endpoint="http://10.10.10.10:8080/gw/someAction?amount=10&description='Somedescription'";$opts=array('http'=>array('method'=>'GET','header'=>'Content-type:application/xml'));$context

php - HTML/PHP : Which parts of an HTML head can be saved in a separate file

我是HTML的新手,希望有人能帮助我解决这个问题。我正在尝试建立一个网站,其中每个页面的代码都保存为一个单独的php文件。由于所有这些页面都使用相同的文档头并包含我想从页面中尽可能多地删除它并将其保存在单独的包含文件中(header.php)然后我可以包括使用PHP。我当前的头看起来如下,因为这在所有页面上都是相同的,我目前将所有这些保存在单独的header.php文件中,然后在单个页面上使用。谁能告诉我其中的哪些部分应该保留在单个页面上以进行正确设置,以及是否应该在此处更改或添加任何内容?注意:jQuery和JS分别包含在页脚中。我的PHP(头文件):MyPage

php - Prestashop : how to override a module class contained in a file that includes other classes?

prestashop覆盖系统通过使用文件命名方案与许多其他系统一样工作。所以基本上,我将在/overrides/classes中创建一个与/classes中另一个具有相同类和文件名的类,只是为了简化。好吧,我必须覆盖它(使用最新的prestashop版本可以覆盖模块,而以前我们不能):include_once(dirname(__FILE__).'/MailAlert.php');classMailAlertsextendsModule{[....]}我可以用这个覆盖它:classMailAlertsOverrideextendsMailAlerts{[....]}好吧,它有效,文件和

php - 在 "anonymous"对象中使用 $this

我正在使用以下类来模拟PHP中的匿名对象:classAnonymousObject{protected$methods=array();publicfunction__construct(array$options){$this->methods=$options;}publicfunction__call($name,$arguments){$callable=null;if(array_key_exists($name,$this->methods))$callable=$this->methods[$name];elseif(isset($this->$name))$callab

php - 拉维尔 5.2 :How to display time like this?

我正在使用Laravel5.2,我想这样显示文章的创建时间:created_atdisplayingin1daytoday2-10days(2-10)daysago>10daysshowcreationdatedirectly怎么做?提前致谢!编辑:Controller:publicfunctionshow($id){$article=Article::findOrFail($id);returnview('show',compact('article'));}查看:{{$article->title}}{{$article->content}}{{$article->created_

PHP file_exists 在不存在的文件上返回 true

我有以下代码片段:这应该做的是从配置文件中读取数据,然后使用它连接到MySQL服务器。如果配置文件不存在,它会重定向到一个设置页面,在该页面中创建文件并填充用户提供的数据。问题是,即使文件不存在,file_exists仍然会返回true,这会导致else分支运行并在所有地方失败。我尝试在文件路径中使用$_SERVER['DOCUMENT_ROOT']以防万一;没有区别。 最佳答案 文档:http://php.net/manual/en/function.file-exists.phpReturnsTRUEifthefileordir

PHP Symfony2 : Delete a temp file after response

我有一个生成图像并在响应中返回图像的Controller。useFOS\RestBundle\Controller\AnnotationsasRest;useSymfony\Component\HttpFoundation\BinaryFileResponse;.../***@Rest\Get("/image/{name}")*/publicfunctiongetImage($name){$imageService=$this->get('image.service');$tempImage=$imageService->genImage($name);returnnewBinaryF

php - 从 PHP 闭包中读取 "this"和 "use"参数

当您在PHP中创建返回闭包的方法时:classExampleClass{publicfunctiontest(){$example=10;returnfunction()use($example){return$example;};}}print_r的结果包含this(其方法创建闭包的类)和static,它似乎是绑定(bind)在其中的值闭包的use()语句:$instance=newExampleClass();$closure=$instance->test();print_r($closure);制作:ClosureObject([static]=>Array([example]

php - 返回带有抽象类的新 $this

我发现我的代码有问题,不明白为什么会这样。谁能给我解释一下?让我们有:abstractclassAbstractThing{publicfunctionsearch(...){$ret=false;$data=$database->query(...);foreach($dataas$values){$item=new$this;$item->fill_with_values($values);$ret[]=$item;}return$ret;}}它按预期工作并在成功搜索时返回对象实例:classThingextendsAbstractThing{//...}$thing=newThi

php - fatal error : Using $this when not in object context - OOPHP

我只是想通过构造函数设置post_id并通过另一个函数获取该id。但它正在返回:fatalerror:不在对象上下文中时使用$this但不知道为什么会这样正在发生。我以前做过很多次,但现在出了问题。代码如下classPostData{privatestatic$instance=null;public$post_id=0;publicfunction__construct($post_id=0){if((int)$post_id>0){$this->setId($post_id);}}privatefunctionsetId($post_id){return$this->post_id