Tag: PHP的

使用PHP从HTTPredirect到HTTPS

我正在购物车网站上工作,我想在用户input帐单详细信息时将用户redirect到HTTPS页面,并在下一页保持HTTPS连接,直到他退出。 我需要在服务器上安装什么(我正在使用Apache)才能做到这一点,以及如何从PHP完成这个redirect?

PHP CLI上的新行

我有一个PHP的CLI脚本,并不能得到输出在新的行中断。 我做 echo 'this is my text\r\n'; echo 'next line'; 这给了 this is my text\r\nnext line 关于如何在不同的线路上获得输出的任何想法?

软件包php5没有安装候选(Ubuntu 16.04)

当我尝试通过使用以下代码在Ubuntu 16.04中安装php5: sudo apt-get install php5 php5-mcrypt 我得到以下错误: Reading package lists… Done Building dependency tree Reading state information… Done Package php5 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'php5' has no installation […]

在PHP中通过整数索引访问关联数组

我想使用键/值对的数组索引来设置关联数组的值。 例如: $my_arr = array( "bling" => "some bling", "bling2" => "lots O bling" ); $my_arr[1] = "not so much bling"; // Would change the value with key bling2. 这怎么可以做到这一点,而不使用密钥string?

在PHP中validation信用卡的最佳方式是什么?

给定一个信用卡号码,没有额外的信息,什么是最好的方式在PHP来确定它是否是一个有效的数字? 现在我需要一些能够与美国运通,Discover,MasterCard和Visa合作的东西,但是如果它也可以与其他types一起使用,这可能会有所帮助。

为什么是$ a + ++ $ a == 2?

如果我尝试这个: $a = 0; echo $a + ++$a, PHP_EOL; echo $a; 我得到这个输出: 2 1 演示: http : //codepad.org/ncVuJtJu 这是为什么? 我希望得到这个作为输出: 1 1 我的理解: $a = 0; // a === 0 echo $a + ++$a, PHP_EOL; // (0) + (0+1) === 1 echo $a; // a === 1 但为什么不是输出?

在Laravel Eloquent中使用“with()”函数获取特定的列

我有两个表User和Post One User有很多posts ,一个post只属于一个user 。 在我的User模型中,我有许多关系 public function post(){ return $this->hasmany('post'); } 而在我的post模式,我有belongsTo像关系 public function user(){ return $this->belongsTo('user'); } 现在我想要使用Eloquent with()join这两个表Eloquent with()但希望第二个表中的特定列。 我知道我可以使用query Builder但我不会使用它。 当我在post模式写我 public function getAllPosts() { return Post::with('user')->get(); } 它运行以下queires select * from `posts` select * from `users` where `users`.`id` in (<1>, <2>) 但我想要 select * from `posts` select id,username from `users` […]

dyld:库没有加载:/usr/local/lib/libjpeg.8.dylib – homebrew php

由于我遇到这个libpng问题 ,PHP并不适合我,所以我重新安装了一个新版本的Homebrew。 不过,这次我得到了libjpeg类似的错误: $ php -v dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib Referenced from: /usr/local/bin/php Reason: image not found Trace/BPT trap: 5 有什么build议么?

用于Eclipse的PHP Mess Detector

我已经安装了PTI Eclipse插件。 有可能改变PDepend , CodeSniffer和UnitTest 当我尝试右键单击任何文件时,我也有一个“ Mess Detector选项,但是单击它时没有任何反应。 而search所有configuration选项后,我找不到任何PHPMD设置。 有谁知道如何解决它?

什么是使用Node.js与PHP的优势?

可能重复: 为什么和何时使用节点js? 有人能告诉我为什么所有这些关于node.js大惊小怪吗? 是一个常规的网站(可以说一个博客)写在node.js比较相同的写在一些PHP框架? 我知道用node.js编写的web服务器比apache要快,但是如果一个真正的web应用程序不能创build线程或类似的东西呢?