草庐IT

PHP 版本 5.4.13 错误?代码点火器错误?或者,解释?

coder 2024-01-04 原文

所以...前几天我推送了一些代码(在我的本地机器上 100% 正常工作)但是杀死了服务器 - 没有 Codeigniter 日志,没有 Apache 日志,die('msg')exit() 不起作用 - 我在 5 年以上的 PHP 开发中从未遇到过这种情况。

在 50 多个提交到我的 repo 之后,我将问题缩小到一个声明,该声明在拆分时有效,但在合并时无效。

系统信息:

PHP Version: 5.4.13

Codeigniter Version: define('CI_VERSION', '2.1.3');

这些行有效(在 Codeigniter MY_Controller 函数中调用):

dump($this->get_val('order_id')); 
$tmp = $this->get_val('order_id');
dump($tmp); 
dump(empty($tmp)); 
dump(!empty($tmp));

但是当我添加以下行时,上述崩溃发生了:

!empty($this->get_val('order_id'))

这似乎是一个 PHP 错误?


结构:

主.php

<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Main extends Administration {

    function index() {
        // if (!empty($in['order_id'])) { /*  BROKEN  */
        dump($this->get_val('order_id'));
        $tmp = $this->get_val('order_id');
        dump($tmp);
        dump(empty($tmp));
        dump(!empty($tmp));
        // dump(!empty($this->get_val('order_id'))); /*  BROKEN  */
        // if (!empty($this->get_val('order_id'))) { /*  BROKEN  */
        //     dump(true);
        // } else {
        //     dump(false);
        // }
    }
}

管理.php

<?php

class Administration {

    /**
     *
     * @var MY_Controller;
     */
    public $ci;
    public $p;

    function __construct() {
        $this->ci = & get_instance();

        $this->ci->load->model('user/admin/user_admin_model');

        $this->p = $this->ci->uri->uri_to_assoc(4);
    }

    protected function get_val($name = '') {
        $pst = (array) $this->ci->input->post();
        $gt = (array) $this->ci->input->get();

        if (empty($name)) {
            return array_merge($pst, $gt, $this->p);
        }

        if (!empty($this->p[$name]))
            return $this->p[$name];
        if (!empty($pst[$name]))
            return $pst[$name];
        if (!empty($gt[$name]))
            return $gt[$name];

        return array();
    }

}

?>

My_Controller.php

<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
class MY_Controller extends CI_Controller {

    protected $p;

    function __construct() {
        parent::__construct();
        $this->p = $this->uri->uri_to_assoc();
    }

    function get_val($name = '') {
        dump("I am get_val in MY_controller");

        $pst = (array) $this->input->post();
        $gt = (array) $this->input->get();

        if (empty($name)) {
            return array_merge($pst, $gt, $this->p);
        }

        if (!empty($this->p[$name]))
            return $this->p[$name];
        if (!empty($pst[$name]))
            return $pst[$name];
        if (!empty($gt[$name]))
            return $gt[$name];

        return array();
    }
}

最佳答案

PHP 5.5.0 之前的版本,empty只作用于变量,而不作用于函数的返回值或直接作用于表达式的结果

关于PHP 版本 5.4.13 错误?代码点火器错误?或者,解释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21637840/

有关PHP 版本 5.4.13 错误?代码点火器错误?或者,解释?的更多相关文章

  1. ruby-on-rails - Rails 常用字符串(用于通知和错误信息等) - 2

    大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje

  2. ruby - 如何在 buildr 项目中使用 Ruby 代码? - 2

    如何在buildr项目中使用Ruby?我在很多不同的项目中使用过Ruby、JRuby、Java和Clojure。我目前正在使用我的标准Ruby开发一个模拟应用程序,我想尝试使用Clojure后端(我确实喜欢功能代码)以及JRubygui和测试套件。我还可以看到在未来的不同项目中使用Scala作为后端。我想我要为我的项目尝试一下buildr(http://buildr.apache.org/),但我注意到buildr似乎没有设置为在项目中使用JRuby代码本身!这看起来有点傻,因为该工具旨在统一通用的JVM语言并且是在ruby中构建的。除了将输出的jar包含在一个独特的、仅限ruby​​

  3. ruby-on-rails - Rails 源代码 : initialize hash in a weird way? - 2

    在rails源中:https://github.com/rails/rails/blob/master/activesupport/lib/active_support/lazy_load_hooks.rb可以看到以下内容@load_hooks=Hash.new{|h,k|h[k]=[]}在IRB中,它只是初始化一个空哈希。和做有什么区别@load_hooks=Hash.new 最佳答案 查看rubydocumentationforHashnew→new_hashclicktotogglesourcenew(obj)→new_has

  4. ruby-on-rails - 项目升级后 Pow 不会更改 ruby​​ 版本 - 2

    我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby​​版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby​​版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘

  5. ruby-on-rails - 在 ruby​​ .gemspec 文件中,如何指定依赖项的多个版本? - 2

    我正在尝试修改当前依赖于定义为activeresource的gem:s.add_dependency"activeresource","~>3.0"为了让gem与Rails4一起工作,我需要扩展依赖关系以与activeresource的版本3或4一起工作。我不想简单地添加以下内容,因为它可能会在以后引起问题:s.add_dependency"activeresource",">=3.0"有没有办法指定可接受版本的列表?~>3.0还是~>4.0? 最佳答案 根据thedocumentation,如果你想要3到4之间的所有版本,你可以这

  6. ruby-on-rails - 迷你测试错误 : "NameError: uninitialized constant" - 2

    我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test

  7. ruby-on-rails - 如何在 Rails View 上显示错误消息? - 2

    我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c

  8. 使用 ACL 调用 upload_file 时出现 Ruby S3 "Access Denied"错误 - 2

    我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file

  9. ruby-on-rails - 错误 : Error installing pg: ERROR: Failed to build gem native extension - 2

    我克隆了一个rails仓库,我现在正尝试捆绑安装背景:OSXElCapitanruby2.2.3p173(2015-08-18修订版51636)[x86_64-darwin15]rails-v在您的Gemfile中列出的或native可用的任何gem源中找不到gem'pg(>=0)ruby​​'。运行bundleinstall以安装缺少的gem。bundleinstallFetchinggemmetadatafromhttps://rubygems.org/............Fetchingversionmetadatafromhttps://rubygems.org/...Fe

  10. ruby - #之间? Cooper 的 *Beginning Ruby* 中的错误或异常 - 2

    在Cooper的书BeginningRuby中,第166页有一个我无法重现的示例。classSongincludeComparableattr_accessor:lengthdef(other)@lengthother.lengthenddefinitialize(song_name,length)@song_name=song_name@length=lengthendenda=Song.new('Rockaroundtheclock',143)b=Song.new('BohemianRhapsody',544)c=Song.new('MinuteWaltz',60)a.betwee

随机推荐