标签: fatal-error

不在对象上下文中时使用 $this php

我刚开始在 php 中学习 OOPS。我写了一个简单的程序来实现继承。当不在对象上下文中时,我收到 $this 的致命错误。谁能解释一下这个错误,这是什么意思?这是我的代码:

<?php

    class human{

        public $gender;

        public function _construct($gender)
        {
            $this->gender=$gender;

            echo $this->get_gender();
        }

        public function get_gender()
        {
            return $this->gender;
        }


    }

    class person extends human{

        public $name;
        public $surname;

        public static function set_name($name)
        {
            $this->name=$name;
        }
        public static function set_surname($surname)
        {
            $this->surname=$surname;
        }

        public static function get_name()
        {
            return $this->name;
        }
        public static function get_surname()
        {
            return $this->surname;
        }
    }

    $john = new person('male');
    $john->set_name('John');
    $john->set_surname('Williams');
    echo $john->get_name().' '.$john->get_surname().'is a '.$john->get_gender();
    ?>
Run Code Online (Sandbox Code Playgroud)

php oop inheritance fatal-error

2
推荐指数
2
解决办法
7354
查看次数

PHP 7 simpleXML 致命错误

我无法用 simplexml 解决问题。

我刚刚在带有 apache2 服务器的 aws linux/ubuntu 上设置了一个 ec2 实例并尝试安装商店。

问题:

Fatal error: Call to undefined function XXX\Recovery\Install\simplexml_load_file() in /var/www/XXX/recovery/install/src/Requirements.php on line 104
Run Code Online (Sandbox Code Playgroud)

搜索已知问题。我想出了手动安装的 php 包。检查 phpinfo 和 php -mi 后,假设安装了以下模块:

[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache …
Run Code Online (Sandbox Code Playgroud)

simplexml fatal-error shopware

2
推荐指数
1
解决办法
7800
查看次数

Gitlab - git clone 在 macOS 中使用 ssh 和 https 均失败

我的同事允许我以 Master 身份访问他的存储库,然后我使用 SSH 和 HTTPS 克隆它,但它总是失败:

GitLab: The project you were looking for could not be found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

我一直在检查.pub文件中生成的公钥并已插入到我的 Gitlab 帐户中。而且我还尝试克隆一个存储库(来自其他所有者),并且可以正常工作!这很混乱。

我错过了什么吗?

git github git-clone fatal-error gitlab

2
推荐指数
1
解决办法
4227
查看次数

EPSON 出现问题,找不到“libepos2.so”

在我将 mSwipe(Card Swiper) 与我的 Android 应用程序集成之前,EPSON 网络打印机工作得非常完美。

集成后现在mSwipe工作正常,但一切都EPSON崩溃了。

libepos2.so里面有src/main/jniLibs/armeabi/libepos2.so但是还是说找不到。

log以下:

FATAL EXCEPTION: main
    Process: com.intuition.dine.ivepos, PID: 10908
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.intuition.dine.ivepos-1/base.apk"],nativeLibraryDirectories=[/data/app/com.intuition.dine.ivepos-1/lib/arm, /data/app/com.intuition.dine.ivepos-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]] couldn't find "libepos2.so"
        at java.lang.Runtime.loadLibrary0(Runtime.java:972)
        at java.lang.System.loadLibrary(System.java:1567)
        at com.epson.epos2.discovery.Discovery.<clinit>(Discovery.java:20)
        at com.epson.epos2.discovery.Discovery.start(Discovery.java)
        at com.intuition.dine.ivepos.SearchIPActivity.onCreate(SearchIPActivity.java:191)
        at android.app.Activity.performCreate(Activity.java:6955)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
        at android.app.ActivityThread.-wrap14(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6776)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激。

android thermal-printer epson fatal-error

2
推荐指数
1
解决办法
3244
查看次数

如何处理 Null 上的 array_shift() ?

请看一下这段代码:

$end = isset($newvar) ? array($newvar) : null;
while($ends = array_shift($end)){
  ...
Run Code Online (Sandbox Code Playgroud)

当我使用 PHP 时它运行良好7.2,但升级到 PHP 后8.1,它会抛出:

PHP 致命错误:未捕获类型错误:array_shift():参数 #1 ($array) 必须是数组类型,在 /path/to/qanda.php:469 中给出 null

知道如何修复它吗?

php fatal-error php-8

2
推荐指数
1
解决办法
150
查看次数

PHP MySQL脚本出错了

我正在一个站点上创建这个实验脚本,该脚本根据数据库条目动态填充类别菜单.

它工作了一天然后突然停了下来.我更改了我的包含需求,它给了我这个错误信息

致命错误:第34行/home1/advertbo/public_html/dev_area/origocloud/include/views/blog/dbget.php超过30秒的最长执行时间

function getBlogMenu(){
$dbhost = 'localhost';
$dbuser = ' ';
$dbpass = ' ';

$con = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$con)
  {
    die('Could not connect: ' . mysql_error());
  }

mysql_select_db("ado_ocblog", $con);

$htmlString = "";

$result = mysql_query(
    "SELECT *
    FROM subCat
    JOIN headCat ON subCat.headid = headCat.id
    ORDER BY headid ASC;");

$array = mysql_fetch_array($result);
mysql_close($con);

$pre = NULL;
$hc = 0;
$sc = 1;
while ($array) {
    if($pre == NULL){
        $pre = $row["headc"];
        $test[0][0]=$row["headc"];
        $test[0][1]=$row["subc"];

    }
    else
    { …
Run Code Online (Sandbox Code Playgroud)

php mysql timeout fatal-error

1
推荐指数
1
解决办法
100
查看次数

PHP call_user_func替代方案

我正在寻找一个相当于PHP的功能call_user_func.我遇到这个函数的问题是它没有进入"对象模式".通过这个,我的意思是我不能$this在课堂上使用和其他东西,所以几乎用两个词:不是oop.

我基本上需要这个,因为我正在处理请求的URL,解析它,并查看一切是否正常等等,然后执行以下行:

call_user_func(array(ucfirst( $controller . "Controller" ),  '_initAction'), $param);       
call_user_func(array(ucfirst( $controller . "Controller" ), $action . 'Action'), $param);
Run Code Online (Sandbox Code Playgroud)

因为我想动态调用"Controller"它的动作.但我不能$this$action方法中使用,因为它不是OOP.

我收到的消息:

Fatal error: Using $this when not in object context in E:\htdocs\wit\application\controller\InformationController.php on line 6
Run Code Online (Sandbox Code Playgroud)

所以我希望有人可以帮助我.

你能否告诉我,我是否以错误的方式处理这个问题?

PS:请不要向我推荐任何处理这些东西的MVC框架.我喜欢Zend,但有时候,它太沉重了:((我需要一个轻量级的设置.

php oop fatal-error

1
推荐指数
1
解决办法
3162
查看次数

在wordpress中使用wp_list_table时出现致命错误

我在一个类中使用wp_list_table时遇到致命的错误,完全我在一个类中扩展了wordpress wp_list_table,然后当我尝试从它实例化一个对象时将其包含到我的插件中,然后调用.display()功能它说:

致命错误:在第87行的/Applications/MAMP/htdocs/wordpress_33/wp-admin/includes/class-wp-list-table.php中调用未定义的函数get_current_screen()

有什么建议吗?

wordpress class fatal-error

1
推荐指数
1
解决办法
3549
查看次数

致命错误:在写上下文中不能使用函数返回值

我有一个非常讨厌的错误,我无法摆脱.这是引起问题的函数:

    function get_info_by_WatIAM($WatIAM, $info) { 
    $users_info = array();
    exec("uwdir -v userid={$WatIAM}", $users_info);
    foreach ($users_info as $user_info) {
        $exploded_info = explode(":", $user_info);
        if (isset($exploded_info[1])){              
            $infoArray[$exploded_info[0]] = $exploded_info[1];
        } 
    }
    return $infoArray[$info];   }
Run Code Online (Sandbox Code Playgroud)

这是调用函数的内容:

} elseif (  empty(get_info_by_WatIAM($_POST['ownerId'])) ) { ... 
Run Code Online (Sandbox Code Playgroud)

我真的很感激任何建议.非常感谢!

如果代码没有意义,这里有一个进一步的解释:exec使用一个程序来存储学校中所有用户的信息.这些包括教师,姓名,用户ID等.这$_POST['ownerId']是一个用户名 - 想法是,输入用户名后,所有用户的信息将自动填写

php post function exec fatal-error

1
推荐指数
1
解决办法
3121
查看次数

使用URL方案在iOS中进行应用程序间通信

我有两个测试应用程序:App1和App2.

App1从文本字段中获取String并触发方法:

@IBAction func openApp(sender: AnyObject) { 
    let url1 = ("app2://com.application.started?displayText="+textToSend.text!)
    let url2 = url1.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())
    UIApplication.sharedApplication().openURL(NSURL(string: url2!)!)
}
Run Code Online (Sandbox Code Playgroud)

这实际上打开了App2,其中只有标签应该更改为通过url发送的文本,代码在AppDelegate.swift中:

func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
    let url = url.standardizedURL
    let query = url?.query
    ViewController().labelToDisplayResult.text = query
    return true;
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,我试图将URL的结果传递给实际标签的行给了我这个错误:

EXC_BAD_INSTRUCTION (CODE=EXC_I386_INVOP SUBCODE=0x0)
Run Code Online (Sandbox Code Playgroud)

但是我确实在App2中有所有数据,因为我可以在调试器中看到它们的值:

url NSURL   "app2://com.application.started?displayText=564315712437124375" 0x00007fa4e3426320
query   String? "displayText=564315712437124375"
Run Code Online (Sandbox Code Playgroud)

知道我为什么会收到这个错误吗?

谢谢...

url fatal-error ios swift

1
推荐指数
1
解决办法
4172
查看次数