草庐IT

loading-code-from-editor-into-con

全部标签

php - 恐惧超时与 'mod_fcgid: read timeout from pipe'

我的应用程序尝试访问超时的URL有问题。我正在trycatch此超时并使用以下代码解决此问题:$timeout=120;if(false==$handle=@fsockopen($host,$port,$errno,$errstr,$timeout)){thrownewException("Couldnotconnecttourl:".$errstr);}$getRequest="GET{$url}HTTP/1.0\r\n";$getRequest.="Host:{$urlParts['host']}\r\n";$getRequest.="Connection:close\r\n\r\

php - 如何简洁地返回 Code Igniter 查询中的第一个结果?

我试图返回一个对象,表示根据模型中的ID检索到的期刊。publicfunctiongetJournal($id){$query=$this->db->query("SELECT*FROMjournalsWHEREid='$id'");return($query->num_rows()==1)?($query->result())[0]:NULL;}但是,PHP会发出一个错误,声明一个意外的右括号([)。我最终实际上循环遍历了1个对象实体的数组以返回它,这很愚蠢但有效。publicfunctiongetJournal($id){$query=$this->db->query("SELEC

php - Magento : Get country code by country name

我试图通过国家名称查找国家代码。所以,例如,我有“荷兰”,我需要得到“NL”我知道有一种方法可以找到名称形式的代码:$country_name=Mage::app()->getLocale()->getCountryTranslation($country_code)但我需要反之亦然。那么Magento中有什么方法可以解决吗? 最佳答案 Fromtheotherquestion,这只能通过循环国家集合来完成$countryId='';$countryCollection=Mage::getModel('directory/count

php - "Expected response code 250 but got code "554 ", with message "554 5.2.0 STOR EDRV“

我想发送一封带附件的电子邮件。使用smtp.office365.com生产环境:ubuntusmtp.office365.com-Laravel5.预期响应代码250但得到代码“554”,消息“5545.2.0STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied;由于消息无法提交消息的永久异常而无法处理消息。本地主机:预期响应代码250但得到代码“530”,消息“5305.7.57SMTP;客户端未通过身份验证,无法在MAILFROM[xxxxxx.xxxx.PROD.OUTLOOK.

PHP : Show the headers received from the browser

因此,当浏览器向服务器发出HTTP请求时,它采用一些header(get/post、cookies、host、UserAgent等)的形式。有没有一种方法可以在php脚本中读取和显示它们?是的,$_GET、$_POST和$_COOKIE都在那里。我正在寻找其余的标题信息。例如http://pgl.yoyo.org/http/browser-headers.php谢谢。 最佳答案 get_headers()功能是你要找的。如引用get_headers—Fetchesalltheheaderssentbytheserverinrespo

PHP/Zend : How to remove all chars from a string and keep only numbers

我只想保留数字并从变量中删除所有字符。例如:input:+012-(34).56.(ASD)+:"{}|78*9output:0123456789 最佳答案 这是一般的做法:$numbers=preg_replace('/[^0-9]+/','','+012-(34).56.(ASD)+:"{}|78*9');echo$numbers;输出:0123456789 关于PHP/Zend:Howtoremoveallcharsfromastringandkeeponlynumbers,我们在

php - 使用 simplexml_load_file() 加载压缩的 XML 文件

我正在尝试使用simplexml_load_file()PHP函数加载一个gzip压缩的XML文件,但我不知道如何解码它以便我可以使用其中的数据。 最佳答案 PHP有supportforzlibcompression内置,只需在文件的路径前加上gzip数据compress.zlib://就可以了:$xml=simplexml_load_file("compress.zlib://test.xml");像魅力一样工作。 关于php-使用simplexml_load_file()加载压缩的X

php - Symfony2 表单集合 : How to remove entity from a collection?

我尝试从集合中删除实体,但它不起作用。我想我在某处有错误,但我不知道在哪里。这是我的updateAction中的代码:$em=$this->getDoctrine()->getEntityManager();$entity=newPerson();if(!$entity){throw$this->createNotFoundException('UnabletofindPersonentity.');}$editForm=$this->createForm(newPersonType(),$entity);$deleteForm=$this->createDeleteForm($id)

Visual Studio Code 中的 PHP 调试会在每次异常时中断

我刚刚开始在VisualStudioCode(Ubuntu14.04)中使用PHP调试扩展。它对我来说大部分工作正常,但我有一个问题,每次抛出异常时,调试器都会自动中断。我们在代码中有很多内部捕获和处理的异常,所以我不想逐一逐一检查。我一直在努力寻找类似ExceptionSettings的东西在VisualStudio2015中,但在VisualStudioCode中找不到任何等效选项。php.ini设置:[debug]xdebug.remote_autostart=onxdebug.remote_enable=onxdebug.remote_handler=dbgpxdebug.re

PHP simplexml_load_file - 捕获文件错误

是否可以捕获simplexml文件错误?我连接到一个有时会失败的网络服务,如果系统返回一些http错误或类似的东西,我需要让系统跳过一个文件。 最佳答案 使用@很脏。如果你看手册,有一个选项参数:SimpleXMLElementsimplexml_load_file(string$filename[,string$class_name="SimpleXMLElement"[,int$options=0[,string$ns=""[,bool$is_prefix=false]]]])此处提供所有选项列表:http://www.php.