草庐IT

string_with_shortcodes

全部标签

php - DOMDocument->saveHTML() vs urlencode with commercial at symbol (@)

使用DOMDocument(),我正在替换$message中的链接并添加一些内容,例如[@MERGEID]。当我使用$dom_document->saveHTML()保存更改时,链接得到“某种”url编码。[@MERGEID]变为%5B@MERGEID%5D。稍后在我的代码中,我需要用ID替换[@MERGEID]。所以我搜索urlencode('[@MERGEID]')-然而,urlencode()将符号(@)处的商业广告更改为%40,而saveHTML()已将其保留。所以没有匹配-'%5B@MERGEID%5D'!='%5B%40MERGEID%5D'现在,我知道可以运行str_re

PHP super 怪异警告: illigal string offset while creating a key

我有一个很奇怪的问题。我正在运行一个foreach循环来编译一个数组,但我收到一个错误。我收到以下警告:警告:中的非法字符串偏移'clientaccount_id'对于这行代码:$this->PreparedData[$table][$field]=0;如果我会做这样的事情,我会说这是合乎逻辑的:$testVariable=$this->PreparedData[$table][$field];那么用'clientaccount_id'填充的变量$field将不存在。但是我正在创建字段“clientaccount_id”,所以对我来说这几乎不可能出错。代码privatefunction

php - pg_escape_string 不工作

我想使用pg_escape_string在我的password谁能告诉我它是如何使用的?在我的postgresqlinsert表格$query="insertintovmobjects(guid,ipaddress,username,password,hostid,vmname,guestostype)values('".$guid."','".$ip."','".$username."','".$password."','".$hostid."','".$name."','".strtolower($os)."')";我正在使用$escaped=pg_escape_string($p

php - 如何将 JPG 图片保存为 4 :2:0 colorspace with Imagick?

GooglePagespeed可以将RGB图像转换为YUV4:2:0色彩空间。我想在PHP中使用imagick做同样的事情。简要说明为什么需要4:2:0:"Thisfilterreducesthecolorsamplingofjpegimagesto4:2:0.Humanvisionismuchmoresensitivetochangesinbrightnessthanchangesinhueorsaturation,and4:2:0colorsamplingallowsustokeepbrightnessdatawhilereducingtheamountofhueandsatura

PHP 日期格式() : How to format date from string value

我有一点PHP代码:$exd=date_create('01Dec,2015');$exd=date_format($exd,'Y-m-d');echo$exd;用于格式化日期。预期输出为2015-12-01但它返回2016-12-01。我错过了什么? 最佳答案 首先使用createFromFormat方法,提供输入格式:$exd=DateTime::createFromFormat('dM,Y','01Dec,2015');//arguments(,)$exd=date_format($exd,'Y-m-d');//thencho

java - PHP 问题 : filesize() return 0 with file containing few data?

我使用PHP调用Java命令,然后将其结果转发到名为result.txt的文件中。例如,该文件包含以下内容:“结果是:5.0”但是函数filesize()返回0,当我通过“ls-l”命令检查时,它也是0。因为我决定在文件大小!=0时将结果打印到屏幕上,所以什么都不打印。我怎样才能得到位的大小?或其他可用的解决方案? 最佳答案 来自docs,当您调用filesize时,PHP会将此结果缓存在stat缓存中。您是否尝试过清除统计缓存?clearstatcache();如果它不起作用,可能的解决方法是打开文件,找到它的末尾,然后使用fte

php - 如何获取两个字符 [string] 之间的字符串? PHP

这个问题在这里已经有了答案:CapturingtextbetweensquarebracketsinPHP(1个回答)关闭去年。$string1="Thisistest[example]";$string2="Thisistest[example][2]";$string3="This[is]test[example][3]";如何得到下面的结果?For$string1->exampleFor$string2->example*2For$string3->is*example*3

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 preg_split : Split string by other strings

我想用一系列单词拆分一个大字符串。例如$splitby=array('these','are','the','words','to','split','by');$text='Thisisthestringwhichneedstobesplitbytheabovewords.';那么结果就是:$text[0]='Thisis';$text[1]='stringwhichneeds';$text[2]='be';$text[3]='above';$text[4]='.';我该怎么做?是preg_split最好的方法,还是有更有效的方法?我希望它尽可能快,因为我将拆分数百MB的文件。

php - 在字符串中执行 WordPress 简码

我有一个可能包含短代码的字符串,例如“这是一个带有[anyshortcode1]的字符串,这是[anyshortcode2]”。我想显示带有短代码的字符串,这些短代码在它们所在的位置运行。当我回显这个字符串时,它不执行短代码,它只是将它们打印出来,将它们留在括号中。我尝试使用如下代码解决此问题:$string_with_shortcodes="thisisastringwith[anyshortcode1]andthisis[anyshortcode2]";$pattern=get_shortcode_regex();preg_match_all("/$pattern/",$strin