Tag: PHP的

安装HTTP使用PHP和Apache过期头

我如何在PHP + Apache中设置expires头文件? 我目前正在使用auto_prepend服务资源gzipped,但我也想最大限度地提高HTTPcaching。 我怎样才能设置这些?

如何防止我的网站页面通过iFrame的第三方网站框架加载

如何在页面加载过程中发现我的页面是作为框架embedded到其他网站的? 我猜引用者请求标题不能帮助我在这里? 谢谢。

如何使用自动加载的PHP名称空间?

我尝试使用自动加载和命名空间时遇到此错误: 致命错误:第10行中的/usr/local/www/apache22/data/public/php5.3/test.php中找不到类“Class1” 谁能告诉我我做错了什么? 这是我的代码: Class1.php: <?php namespace Person\Barnes\David { class Class1 { public function __construct() { echo __CLASS__; } } } ?> test.php的: <?php function __autoload($class) { require $class . '.php'; } use Person\Barnes\David; $class = new Class1(); ?>

如果我使用下拉菜单,是否必须防范SQL注入?

我知道你永远不要信任表单中的用户input,主要是由于SQL注入的机会。 但是,这是否也适用于唯一的input来自下拉列表(见下文)的表单? 我将$_POST['size']到一个会话中,然后在整个站点中使用它来查询各种数据库(使用mysqli Select查询),任何SQL注入都肯定会损害(可能会丢失)它们。 有没有types的用户input查询数据库的区域,只有下拉(S)。 <form action="welcome.php" method="post"> <select name="size"> <option value="All">Select Size</option> <option value="Large">Large</option> <option value="Medium">Medium</option> <option value="Small">Small</option> </select> <input type="submit"> </form>

获取下一个和前一天的PHP

我有2个箭头设置,点击第二天,接下来的2天,即将和前一天,2天前,即将。 代码似乎不工作? 因为它只有下一个和前一天。 <a href="home.php?date=<?= date('Ym-d', strtotime('-1 day', strtotime($date))) ?>" class="prev_day" title="Previous Day" ></a> <a href="home.php?date=<?= date('Ym-d', strtotime('+1 day', strtotime($date))) ?>" class="next_day" title="Next Day" ></a> 有没有办法,如果我点击下一个button,date将持续改变第二天。 一会儿它只会提前一天

使用Doctrine 2执行原始SQL

我想使用Doctrine 2执行原始SQL 我需要截断数据库表,并用默认的testing数据初始化表。

Php中的多个分隔符处于爆炸状态

我有一个问题,我有一个string数组,我想爆炸在不同的分隔符。 例如 $example = 'Appel @ Ratte'; $example2 = 'apple vs ratte' 我需要一个数组,它爆炸在@或vs. 我已经写了一个解决scheme,但是如果大家有更好的解决scheme,请在这里发帖。 private function multiExplode($delimiters,$string) { $ary = explode($delimiters[0],$string); array_shift($delimiters); if($delimiters != NULL) { if(count($ary) <2) $ary = $this->multiExplode($delimiters, $string); } return $ary; }

尝试在Mac OS狮子的MAMP中安装带有PECL的OAUTH时出现问题

我是新的设置php服务器,我已经去其他相关的post,似乎没有人有像我一样的错误。 我正在使用MAMP 2.0.2,并运行PHP 5.3.6,并试图在我的本地MAMP上安装oAuth,使用以下命令: $ cd /Applications/MAMP/bin/php/php5.3.6/bin $ ./pecl install oauth 但是,它返回这样的错误: Notice: unserialize(): Error at offset 276 of 1133 bytes in Config.php on line 1050 ERROR: The default config file is not a valid config file or is corrupted. 发生什么事? PECL捆绑在MAMP中,应该是开箱即用的…. 更新: 我在其他地方读了一篇文章,提示configuration文件的数据,其中包含安装path是不正确的,所以我改变了一些值在下面的文件: /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf 然后,我使用命令: $ ./pecl install oauth 它开始下载并解压缩,但是当它尝试安装时,它会提供: creating libtool appending configuration […]

curl错误:接收失败:由对等重置的连接 – PHP Curl

我有这个奇怪的错误, curl错误:接收失败:连接重置由对等 这是如何发生的,如果我没有连接到服务器,并突然尝试通过PHP中的CURL连接到服务器,我得到的错误。 当我再次运行CURL脚本时,错误消失,然后一直运行良好,如果我将远程服务器空闲大约30分钟,或者重新启动远程服务器并尝试再次连接,则会再次出现错误。 所以看起来连接是空闲的,然后突然服务器醒来,然后工作,然后再次睡觉。 这是我的CURL脚本的外观。 $url = Yii::app()->params['pdfUrl']; $body = 'title='.urlencode($title).'&client_url='.Yii::app()->params['pdfClientURL'].'&client_id='.Yii::app()->params['pdfClientID'].'&content='.urlencode(htmlentities($content)); $c = curl_init ($url); $body = array( "client_url"=>Yii::app()->params['pdfClientURL'], "client_id"=>Yii::app()->params['pdfClientID'], "title"=>urlencode($title), "content"=>urlencode($content) ); foreach($body as $key=>$value) { $body_str .= $key.'='.$value.'&'; } rtrim($body_str,'&'); curl_setopt ($c, CURLOPT_POST, true); curl_setopt ($c, CURLOPT_POSTFIELDS, $body_str); curl_setopt ($c, CURLOPT_RETURNTRANSFER, true); curl_setopt ($c, CURLOPT_CONNECTTIMEOUT , 0); curl_setopt ($c, CURLOPT_TIMEOUT , 20); […]

Symfony2和date_default_timezone_get() – 依靠系统的时区设置是不安全的

我有一个Symfony2项目。 我今天更新了我的PHP到5.5.7,从那以后,我得到了 Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for […]