草庐IT

index_name

全部标签

php - 通知 : Undefined index: HTTP_X_FORWARDED_FOR Error in Function

我收到通知:未定义索引:以下函数中的HTTP_X_FORWARDED_FOR:function_ip(){return(preg_match("/^([d]{1,3}).([d]{1,3}).([d]{1,3}).([d]{1,3})$/",$_SERVER['HTTP_X_FORWARDED_FOR'])?$_SERVER['HTTP_X_FORWARDED_FOR']:$_SERVER['REMOTE_ADDR']);} 最佳答案 您应该使用getenv()方法而不是$_SERVER。function_ip(){if(preg_

php - 强制 func_get_args() 的结果是一个关联数组而不是 0-index

想知道是否有可能像func_get_args()(reference)那样调用,而不是生成一个0索引数组,而是生成一个关联数组,使用变量名作为key?例如:functionfoo($arg1,$arg2){var_dump(func_get_args());}foo('bar1','bar2');//Outputarray(2){[0]=>string(4)"bar1"[1]=>string(4)"bar2"}//Preferredarray(2){[arg1]=>string(4)"bar1"[arg2]=>string(4)"bar2"}我问的原因是,我需要验证这些作为数组传递给R

php - 为什么我在 PHP 中使用 cookie 时得到 undefined index ?

如果我使用下面的基本代码if(!defined('NAME_COOKIE'))define('NAME_COOKIE',"storedusername");$cookie_domain=".".$_SERVER['HTTP_HOST'];setcookie(NAME_COOKIE,$username,time()+(86400),"/",$cookie_domain);print$_COOKIE[NAME_COOKIE];脚本在打印过程中因undefinedindex错误而终止。我做错了什么? 最佳答案 你的台词:setcookie

php - 如何删除 url (/web/index.php) yii 2 并使用干净的 url 参数设置路由?

第一个问题:我已经删除了index.php,但我还想删除/web。这是我的.htaccessRewriteEngineon#Ifadirectoryorafileexists,useitdirectlyRewriteCond%{REQUEST_FILENAME}!-fRewriteCond%{REQUEST_FILENAME}!-d#Otherwiseforwardittoindex.phpRewriteRule.index.php这是config/web.php'urlManager'=>['class'=>'yii\web\UrlManager',//Disableindex.ph

php - 通知 : Undefined index: XXX - Does it really matter?

自从我将错误报告级别更改为error_reporting(E_ALL|E_STRICT);我就遇到了这个错误。我可以使用isset()避免这个错误,但代码看起来太丑了!所以我的问题是:如果我回到正常的错误报告设置怎么办?知道某些东西还没有定义真的很重要吗?因为它可以正常工作而不会出现Notice错误。因为我有+10个输入并且我是这样得到它们的:$username=$_POST['username'];我还尝试在文件顶部使用它来预定义变量。$username=null;和$username=0;但它们不起作用。谢谢。 最佳答案 这很重

php - 将 2 个正则表达式合并为一个时得到 "two named subpatterns have the same name"

我试图将2个具有相同名称的不同正则表达式合并为一个,但得到的错误消息如下:Warning:preg_match():Compilationfailed:twonamedsubpatternshavethesamenameatoffset276...一个正则表达式如下所示:'%[\s\S]*?(?P[\s\S]*?)%'另一个看起来像这样:'%[\s\S]*?(?P[\s\S]*?)%'我可以毫无问题地按以下方式组合它们:'%([\s\S]*?(?P[\s\S]*?)|[\s\S]*?(?P[\s\S]*?))%'但我不喜欢这种方式,因为我使用了2个名字。我想知道是否有更好的方法来解决这

php - 文件()[函数.文件] : php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution

从文件("http://www.otherdomain.com")获取内容时出现以下错误。file()[function.file]:php_network_getaddresses:getaddrinfofailed:Temporaryfailureinnameresolution域服务器是linux。如何解决这个问题? 最佳答案 引用:Ifyou'rehavingproblemswithfopen("url...")butyoucanrun'hosturl'inashellwindowandgetthecorrectlookup

php oci_bind_by_name float

我需要将float绑定(bind)到OCI语句。我在做什么:$price=0.1oci_bind_by_name($resource,'price',$price);在我的Oracle数据库中,“价格”是存储过程的一个参数,它的类型是NUMERIC。执行语句后出现以下错误:Message:oci_execute()[function.oci-execute]:ORA-06502:PL/SQL:numericorvalueerror:charactertonumberconversionerrorORA-06512:atline1如果$price是一个整数,一切正常。在PHP文档中htt

php - curl 错误 (35) : error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 unrecognized name

我一直在使用以下代码块通过cURL从HTTPS网站收集数据。$q='https://www.example.org/';//forexample$ch=curl_init();curl_setopt($ch,CURLOPT_URL,$q);curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);curl_setopt($ch,CURLOPT_FOLLOWLOCATION,TRUE

php - "Object named IIS_IUSRS could not be found"将用户添加到 PHP session 目录 iis 8

我正在运行运行IIS8的WindowsServer2012R2。整个WindowsServer环境的新功能。要安装PHP,我将遵循以下教程InstallandConfigurePHP其中一部分说,为了正确使用PHP的session功能,我需要创建一个新文件夹“sessions”并将“IIS_IUSRS”添加到该文件夹​​。但是,当我在“对象文件框”中输入相同内容时,出现“未找到名为IIS_IUSRS的对象”错误。到目前为止,我已经提到了以下内容,但没有一个有帮助TryingtoaddIIS_IUSRStoAdministratorsgroup[closed]IISorIIS_IUSRS