草庐IT

get_term_by

全部标签

php - preg_replace file_get_contents 中不包含单词的所有链接

这个问题在这里已经有了答案:Regularexpressiontomatchalinethatdoesn'tcontainaword(33个答案)关闭9年前。我正在将一个页面读入一个变量,我想禁用地址中不包含单词“remedy”的所有链接。到目前为止,我的代码获取了所有链接,包括带有“补救措施”的链接。我做错了什么?$page=preg_replace('~(.*?)~i','$1',$page);--解决方案--$page=preg_replace('~(.*?)~i','$2',$page);

php - 如何从url中隐藏GET变量

我一直坚持这个"/>,我试图隐藏$_GET可变但没有成功。我想要实现的是www.mywebsitename.com/profile/name或www.mywebsite.com/name而不是profile.php?u=name有可能吗? 最佳答案 对于您的URL:http://localhost/ifinal/profile/myname您可以将like与htaccess一起使用:RewriteEngineOnRewriteBase/ifinal/RewriteCond%{REQUEST_FILENAME}!-fRewriteCo

php - 如何防止 curl 或 file_get_contents 从服务器端访问我的页面

我在大约2小时内遇到了一个问题。谁能提供解决方案,我将不胜感激。http://mydowmin.com/userdatapage.php注意:我不想使用Curl函数从外部世界访问此页面如何避免这个脚本$ch=curl_init("http://mydowmin.com/userdatapage.php");curl_setopt($ch,CURLOPT_CERTINFO,1);curl_setopt($ch,CURLOPT_VERBOSE,1);curl_exec($ch)ordie;print_r(curl_getinfo($ch));http://mydomain.com/data

php - 关于PHP的变量call-by-value和call-value-reference

我对PHP处理变量赋值的方式有疑问。我们有以下声明:$myVariable="value";上述语句为变量$myVariable赋值,然后为其分配内存位置。但是如果我们在上面的脚本中加入如下语句:$secondVariable=$myVariable;然后:关于性能问题,建议避免重复值,如果值不会改变,则继续使用引用(C++,Dietel&Dietel的名著HowtoPrograminC++)但是PHP呢?我听说,刚刚听说,PHP做了一些技巧并通过按引用调用而不是按值调用来管理此类重复($secondVariable=$myVarible),并且在某些更改发生之前不复制变量$secon

PHP Predis : how to get/delete keys containing special characters?

我需要删除一个包含一些特殊键的键(在我的例子中是方括号):我做了以下,但它不起作用:$this->redis;$keys=$this->redis->keys("*");foreach($keysas$key){//keysareinthefollowingformat://vir3_data_cache[zones_cdc_shifting_series_2013_5][1]$this->redis->del($key);//nokeywasdeleted}我也尝试引用key,但没有成功:$this->redis;$keys=$this->redis->keys("*");forea

php - file_get_contents 的超时在 PHP 中不起作用

我创建了一个类来在PHP中包含一些HTTP方法。在这里,我有一个用于HTTPPOST的方法publicfunctionpost($content,$timeout=null){$timeInit=newDateTime();$this->method='POST';$header=array();$header['header']=null;$header['content']=is_array($content)?http_build_query($content):$content;$header['method']=$this->method;if($timeout!=NULL)

php - Yii 2 : Can I access a variable in a view that's rendered by another view?

在Yii2中,遵循MVC模式,Controller将某些变量传递给View。但是,有时View本身会呈现另一个View。例如,在默认生成的CRUDView中,create.php和update.php都呈现_formView:render('_form',['model'=>$model,])?>我是否可以使用Controller传递的变量来_form中的create.php?假设Controller像这样呈现它:return$this->render('create',['model'=>$model,'myVar'=>$myValue,]);现在我可以在create.php中访问$

php - file_get_contents https 超时 1 分钟?

当通过https访问某些资源时,我遇到了PHP的file_get_contents挂起60秒的问题。我不确定这是客户端还是服务器端问题。在客户端在命令行上工作:$URL="https://example.com/some/path"$wget"$URL"-O/dev/null-q#takesafewmilliseconds$curl"$URL">/dev/null#takesafewmilliseconds$php-r'file_get_contents("'"$URL"'")'#takes61s!在服务器上为正确的SSLvhost立即向Apache(2.4)访问日志写入一行,并返回2

PHP:$_GET 中的奇怪字符串编码

我有以下字符串由客户端发送到服务器:3%D3%E1f%7C%AF%B0a%B58%81%92%F9M%90%0CD%A0Y%9C//stringintheactualURL3Óáf|¯°aµ8’ùMDYœ//var_dump($_GET)原始字符串应该是:33D3E1667CAFB061B5388192F94D900C44A0599C我的问题是我不知道如何对此进行编码/解码以便我可以执行数据库搜索,因为归类类型不匹配。我尝试了urlencode/urldecode、mb_string_convert、utf8_encode、iconv,但是没有运气。有什么想法吗?Laravel在尝试使

php - 使用 PHP 的 file_get_contents 后将类添加到 SVG 元素

我需要获取SVG图像并将图像插入页面。我正在使用以下方法获取图像:输出类似插入到页面后如何向SVG元素添加类?如:或定位到路径元素:任何帮助都会很好,谢谢! 最佳答案 您可以将svg存储为PHP变量,然后使用DOMDocument()功能来完成此操作。$svg=file_get_contents("logo.svg");$dom=newDOMDocument();$dom->loadHTML($svg);foreach($dom->getElementsByTagName('svg')as$element){$element->se