Fatal error uncaught error operator not supported for strings in

Доброго времени суток. Пытаюсь мигрировать с php 5 на 7ю версию, столкнулся со следующей проблемой. Выпадает следующая ошибка: Fatal error: Uncaught...

За последние 24 часа нас посетили 11467 программистов и 1168 роботов. Сейчас ищут 307 программистов …


  1. Fatth

    С нами с:
    27 ноя 2018
    Сообщения:
    2
    Симпатии:
    0

    Доброго времени суток.

    Пытаюсь мигрировать с php 5 на 7ю версию, столкнулся со следующей проблемой. Выпадает следующая ошибка:

    1. Fatal error: Uncaught Error: [] operator not supported for strings in
    2. /usr/share/httpd/html/xmpp/XMLStream.php:467 Stack trace:
    3. #0 /usr/share/httpd/html/cu.php(17): XMPPHP_XMLStream->processUntil(Array)
    4. #1 /usr/share/httpd/html/cu.php(7): sendMessage(‘Well done’)
    5. #2 {main} thrown in /usr/share/httpd/html/xmpp/XMLStream.php on line 467

    1.   public function processUntil($event, $timeout=-1) {
    2.       $event = array($event);      //   < строка 467
    3.     $event_key = key($this->until);
    4.     $this->until_count[$event_key] = 0;
    5.     while (!$this->disconnected and $this->until_count[$event_key] < 1 and (time() $start < $timeout or $timeout == 1)) {
    6.       $payload = $this->until_payload[$event_key];
    7.       unset($this->until_payload[$event_key]);
    8.       unset($this->until_count[$event_key]);
    9.       unset($this->until[$event_key]);


  2. Fell-x27

    Команда форума
    Модератор

    С нами с:
    25 июл 2013
    Сообщения:
    12.162
    Симпатии:
    1.770
    Адрес:
    :сердА

    Перепроверьте, тот ли файл. Потому что ошибка не имеет ничего общего с происходящим в этой строке.


  3. nospiou

    С нами с:
    4 фев 2018
    Сообщения:
    3.400
    Симпатии:
    510

    Думаю ошибка в +1. $this->until строка а ты применяешь к ней []


  4. Fatth

    С нами с:
    27 ноя 2018
    Сообщения:
    2
    Симпатии:
    0

    Исправил

    на

    заработало

    Ещё одна ошибка в 571 строке

    1. Fatal error: Uncaught Error: Function name must be a string in /usr/share/httpd/html/xmpp/XMLStream.php:571
    2. #0 [internal function]: XMPPHP_XMLStream->endXML(Resource id
    3. #1 /usr/share/httpd/html/xmpp/XMLStream.php(422): xml_parse(Resource id
    4. #1, ‘<stream:feature…’, false)
    5. #2 /usr/share/httpd/html/xmpp/XMLStream.php(474): XMPPHP_XMLStream->__process()
    6. #3 /usr/share/httpd/html/cu.php(17): XMPPHP_XMLStream->processUntil(Array)
    7. #4 /usr/share/httpd/html/cu.php(7): sendMessage(‘Well’)
    8. #5 {main} thrown in /usr/share/httpd/html/xmpp/XMLStream.php on line 571

    29 строка в этом контексте кода и 571 в моём файле, в комментариях указал.

    1.   public function endXML($parser, $name) {
    2.   #$this->log->log(«Ending $name»,  XMPPHP_Log::LEVEL_DEBUG);
    3.   $this->been_reset = false;
    4.   if ($this->xml_depth == 1) {
    5.  #$found = false; #FIXME This didn’t appear to be in use —Gar
    6.  foreach ($this->xpathhandlers as $handler) {
    7.   $searchxml = $this->xmlobj[2];
    8.   if (($nstag[0] == null or $searchxml->ns == $nstag[0]) and ($nstag[1] == «*» or $nstag[1] == $searchxml->name)) {
    9.   foreach ($handler[0] as $nstag) {
    10.   if ($searchxml !== null and $searchxml->hasSub($nstag[1], $ns = $nstag[0])) {
    11.   $searchxml = $searchxml->sub($nstag[1], $ns = $nstag[0]);
    12.   if ($searchxml !== null) {
    13.   if ($handler[2] === null)
    14.   $this->log->log(«Calling {$handler[1]}«, XMPPHP_Log::LEVEL_DEBUG);
    15.   $handler[2]->$handler[1]($this->xmlobj[2]);  /// <<<<  571 строка с ошибкой
    16.   foreach ($this->nshandlers as $handler) {
    17.   if ($handler[4] != 1 and array_key_exists(2, $this->xmlobj) and $this->xmlobj[2]->hasSub($handler[0])) {
    18.   $searchxml = $this->xmlobj[2]->sub($handler[0]);
    19.   $searchxml = $this->xmlobj[2];
    20.   if ($searchxml !== null and $searchxml->name == $handler[0] and ($searchxml->ns == $handler[1] or (!$handler[1] and $searchxml->ns == $this->default_ns))) {
    21.   if ($handler[3] === null)
    22.   $this->log->log(«Calling {$handler[2]}«, XMPPHP_Log::LEVEL_DEBUG);
    23.   $handler[3]->$handler[2]($this->xmlobj[2]);
    24.   foreach ($this->idhandlers as $id => $handler) {
    25.   if (array_key_exists(‘id’, $this->xmlobj[2]->attrs) and $this->xmlobj[2]->attrs[‘id’] == $id) {
    26.   if ($handler[1] === null)
    27.   $handler[1]->$handler[0]($this->xmlobj[2]);
    28.   #id handlers are only used once
    29.  unset($this->idhandlers[$id]);
    30.   if (isset($this->xmlobj[0]) && $this->xmlobj[0] instanceof XMPPHP_XMLObj) {
    31.   $this->xmlobj[0]->subs = null;
    32.   if ($this->xml_depth == 0 and !$this->been_reset) {
    33.   if (!$this->disconnected) {
    34.   if (!$this->sent_disconnect) {
    35.   $this->send($this->stream_end);
    36.   $this->disconnected = true;
    37.   $this->sent_disconnect = true;
    38.   $this->event(‘end_stream’);

    Заранее спасибо за помощь


  5. nospiou

    С нами с:
    4 фев 2018
    Сообщения:
    3.400
    Симпатии:
    510

    1. $handler[2]->{$handler[1]}($this->xmlobj[2]);


  6. Sail

    С нами с:
    1 ноя 2016
    Сообщения:
    1.524
    Симпатии:
    345


  7. i-grek

    С нами с:
    20 июн 2019
    Сообщения:
    1
    Симпатии:
    0

    Ошибку вызывают пустые скобки [] . А так как эта конструкция часто используется для формирования числового массива в цикле, то заполняем их при помощи дополнительной переменной
    <?
    $d = 0;
    for($arResult as $item):
    $arName[$d] = $item[‘NAME’];
    $d++;
    endforeach;
    unset($d);
    ?>

Comments

@dterweij

Updated my system to PHP 7.1.0 and got this after a git pull to have most recent code:

[danny@server03 spotweb]$ php retrieve.php
Removing Spot information which is beyond retention period,, done
Last retrieve at Sun 04 Dec 2016 11:12:16 PM UTC
Retrieving new Spots from server xxxxxxxxxxx...
Appr. Message count:    2969126
First message number:   2
Last message number:    2969128
Current article number: 2968442

Retrieving 2968442 till 2969129PHP Fatal error:  Uncaught Error: [] operator not supported for strings in /home/danny/public_html/spotweb/lib/services/Format/Services_Format_Parsing.php:140
Stack trace:
#0 /home/danny/public_html/spotweb/lib/services/Retriever/Services_Retriever_Spots.php(492): Services_Format_Parsing->parseFull('<Spotnet><Posti...')
#1 /home/danny/public_html/spotweb/lib/services/Retriever/Services_Retriever_Base.php(227): Services_Retriever_Spots->process(Array, '2968442', 2969129, 1481079369.404)
#2 /home/danny/public_html/spotweb/lib/services/Retriever/Services_Retriever_Base.php(319): Services_Retriever_Base->loopTillEnd(2969129, '5000')
#3 /home/danny/public_html/spotweb/retrieve.php(145): Services_Retriever_Base->perform()
#4 {main}
  thrown in /home/danny/public_html/spotweb/lib/services/Format/Services_Format_Parsing.php on line 140
[danny@server03 spotweb]$
[danny@server03 spotweb]$ php -v
PHP 7.1.0 (cli) (built: Dec  1 2016 08:23:35) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.1.0, Copyright (c) 1999-2016, by Zend Technologies
[danny@server03 spotweb]$

@mesa57

Do you get this error for every spot ?

________________________________
Van: Danny Terweij <notifications@github.com>
Verzonden: woensdag 7 december 2016 04:06
Aan: spotweb/spotweb
Onderwerp: [spotweb/spotweb] Fatal error: Uncaught Error: [] operator not supported for strings in PHP 7.1.0 (#243)

Updated my system to PHP 7.1.0 and got this after a git pull to have most recent code:

[danny@server03 spotweb]$ php retrieve.php
Removing Spot information which is beyond retention period,, done
Last retrieve at Sun 04 Dec 2016 11:12:16 PM UTC
Retrieving new Spots from server xxxxxxxxxxx…
Appr. Message count: 2969126
First message number: 2
Last message number: 2969128
Current article number: 2968442

Retrieving 2968442 till 2969129PHP Fatal error: Uncaught Error: [] operator not supported for strings in /home/danny/public_html/spotweb/lib/services/Format/Services_Format_Parsing.php:140
Stack trace:
#0 /home/danny/public_html/spotweb/lib/services/Retriever/Services_Retriever_Spots.php(492): Services_Format_Parsing->parseFull(‘<Spotnet><Posti…’)
#1 /home/danny/public_html/spotweb/lib/services/Retriever/Services_Retriever_Base.php(227): Services_Retriever_Spots->process(Array, ‘2968442’, 2969129, 1481079369.404)
#2 /home/danny/public_html/spotweb/lib/services/Retriever/Services_Retriever_Base.php(319): Services_Retriever_Base->loopTillEnd(2969129, ‘5000’)
#3 /home/danny/public_html/spotweb/retrieve.php(145): Services_Retriever_Base->perform()
#4 {main}
thrown in /home/danny/public_html/spotweb/lib/services/Format/Services_Format_Parsing.php on line 140
[danny@server03 spotweb]$

[danny@server03 spotweb]$ php -v
PHP 7.1.0 (cli) (built: Dec 1 2016 08:23:35) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.1.0, Copyright (c) 1999-2016, by Zend Technologies
[danny@server03 spotweb]$


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#243>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AGDmhZMgkEHkmFd6JxM7dgxG_Vhn0d0oks5rFiLTgaJpZM4LGJar>.

@dterweij

It is PHP Design.
Changed in PHP 7.1.0:

The empty index operator (e.g. $str[] = $x) is not supported for strings
anymore, and throws a fatal error instead of silently converting to array.

So that means that you need to say that it is an array $myString = array();
Prior to PHP 7.1.0 , PHP converted a [] to array() silently, and now not anymore.

The GUI is showed in browser without new spots. Dont know if there are more places in the code with this kind of error.

@mesa57

Yes, there are numerous places were an [] is used.

@GeoffreyDijkstra

@mesa57 It’s not an issue with [] we can still use that, but you have to initialize it now. So:
$var1[] = $x results in error when not initialized.
$var1 = []; $var1[] = $x does not 😄
It seems they become a little more strict.

@Sweepr

Well, sure, but if we change this way, would it be backwards compatible with older versions of PHP?

Nobody ever said spotweb is designed for PHP 7, so i do not understand why everyone is trying to run spotweb on PHP 7, and start complaining about issue’s.

This way its almost impossible to mantain a stable version..

@GeoffreyDijkstra

@Sweepr Yes this is backwards compatible to 5.4. It’s even not nice/good practice to code without initializing. But PHP accepted it and fixed it for you. So now we need to fix it ourselfs 😁

@Sweepr

@GeoffreyDijkstra

@Sweepr Well, almost 😄
I’ll make a PR and test it on PHP 7.1.

@dterweij

That does not work well :) I don’t paste all the errors because its tooo much :)

PHP Warning: Invalid argument supplied for foreach() in Services_Format_Parsing.php on line 190

A lot of these:
PHP Notice: A non well formed numeric value encountered
PHP Warning: Illegal string offset ….

@GeoffreyDijkstra

@Sweepr

Ok, strange, i did just like @GeoffreyDijkstra suggested,

$var1[] = $x results in error when not initialized.
$var1 = []; $var1[] = $x does not

So i changed the lines containing like:
$var1[] = $x
into
$var1 = []; $var1[] = $x

This apperantly does not do the trick.

@GeoffreyDijkstra

@Sweepr @dterweij Just dived into the code but it’s fine as is… Can run retriever without problems on PHP 5.6, PHP 7.0 and PHP 7.1. So I’m open to suggestions.

@GeoffreyDijkstra

I’ll see if I can find something weird, but for now it’s just doing what it should do.

@GeoffreyDijkstra

@dterweij I’ve cleaned up the file a bit in a hotfix/php71-support branch. If you can checkout this branch and run your retriever.php again, see if it works or crashes. If it crashes, please send another stacktrace.

@dterweij

»’danny@server03 spotweb]$ git branch

  • hotfix/php71-support
    master
    [danny@server03 spotweb]$ php retrieve.php —force
    Removing Spot information which is beyond retention period,, done
    Last retrieve at Sun 04 Dec 2016 11:12:16 PM UTC
    Retrieving new Spots from server Xxxxxxx…
    Appr. Message count: 2970389
    First message number: 2
    Last message number: 2970391
    Current article number: 2968442

Retrieving 2968442 till 2970392PHP Fatal error: Uncaught Error: [] operator not supported for strings in /home/danny/public_html/spotweb/lib/services/Format/Services_Format_Parsing.php:158
Stack trace:
#0 /home/danny/public_html/spotweb/lib/services/Retriever/Services_Retriever_Spots.php(492): Services_Format_Parsing->parseFull(‘<Posti…’)
#1 /home/danny/public_html/spotweb/lib/services/Retriever/Services_Retriever_Base.php(227): Services_Retriever_Spots->process(Array, ‘2968442’, 2970392, 1481425981.5017)
#2 /home/danny/public_html/spotweb/lib/services/Retriever/Services_Retriever_Base.php(319): Services_Retriever_Base->loopTillEnd(2970392, ‘5000’)
#3 /home/danny/public_html/spotweb/retrieve.php(146): Services_Retriever_Base->perform()
#4 {main}
thrown in /home/danny/public_html/spotweb/lib/services/Format/Services_Format_Parsing.php on line 158
[danny@server03 spotweb]$»’

@GeoffreyDijkstra

@dterweij Thx, I introduced a fix into the hotfix branch which I think solves your issues. Can you do a git pull on the hotfix branch and try again?

@dterweij

@GeoffreyDijkstra Here the new report (I did stopped it because it looks like running endless)

[danny@server03 spotweb]$ php retrieve.php
Removing Spot information which is beyond retention period,, done
Last retrieve at Sun 04 Dec 2016 11:12:16 PM UTC
Retrieving new Spots from server xxxxxxxxx...
Appr. Message count:    2980133
First message number:   2
Last message number:    2980135
Current article number: 2968442

Retrieving 2968442 till 2973443PHP Notice:  A non well formed numeric value encountered in /home/danny/public_html/spotweb/lib/services/Retriever/Services_Retriever_Spots.php on line 103
PHP Warning:  Illegal string offset 'exponent' in /home/danny/public_html/spotweb/lib/services/Nntp/Services_Nntp_SpotReading.php on line 38
PHP Warning:  Illegal string offset 'modulo' in /home/danny/public_html/spotweb/lib/services/Nntp/Services_Nntp_SpotReading.php on line 39
PHP Warning:  Illegal string offset 'modulo' in /home/danny/public_html/spotweb/lib/services/Signing/Services_Signing_Openssl.php on line 25
PHP Warning:  Illegal string offset 'exponent' in /home/danny/public_html/spotweb/lib/services/Signing/Services_Signing_Openssl.php on line 25
PHP Warning:  Illegal string offset 'modulo' in /home/danny/public_html/spotweb/lib/services/Signing/Services_Signing_Openssl.php on line 30
PHP Warning:  Illegal string offset 'exponent' in /home/danny/public_html/spotweb/lib/services/Signing/Services_Signing_Openssl.php on line 31
PHP Warning:  Illegal string offset 'modulo' in /home/danny/public_html/spotweb/lib/services/Signing/Services_Signing_Openssl.php on line 25
PHP Warning:  Illegal string offset 'exponent' in /home/danny/public_html/spotweb/lib/services/Signing/Services_Signing_Openssl.php on line 25
PHP Warning:  Illegal string offset 'modulo' in /home/danny/public_html/spotweb/lib/services/Signing/Services_Signing_Openssl.php on line 30
PHP Warning:  Illegal string offset 'exponent' in /home/danny/public_html/spotweb/lib/services/Signing/Services_Signing_Openssl.php on line 31

Seems the array error is solved.

@GeoffreyDijkstra

Ok that’s good to know, strange you have so many problems. Can you run php -v and php -m on your command line and send me the output? And please also send me your php.ini file. Maybe then I can locally reproduce.

@dterweij

@GeoffreyDijkstra

@dterweij Thx, no time take a deeper look today. But I already noticed you use extremely high settings for input, execution time and memory. Just out of curiosity whats the reason for that?

@dterweij

The reason is running a minecraft pocketmine server (that is PHP based, search for it at github) and I dont like standard limits :) I realy hate when I get a limit on shared hosting platforms.
For example, uploading 500 photo’s to a gallery at a WordPress site sucks :)
I am running my own Dell R300 19inch 1U rackserver at home. Running linux since RedHat 1.0 came out :)

@Sweepr

@dterweij Yikes, but that’s around 5 hours of input and exec time, let alone the memory limit of 1024?

That’s insane,.

@dterweij

The pocketmine server uses that much (every github clone).. But lets stay on topic :) Lets chat somewhere else about the high settings 🎱 :-)

Want to know if someone else also tried PHP7.1 and got such or other errors, or am I the first and only one yet :)

@GeoffreyDijkstra

@dterweij Well I’m running it specially for you and it works out of the box, no errors at all… Before that I ran PHP 7.0 which also worked fine, so that’s why I said that it is kinda weird you got so many errors because I got none…

I’m running Ubuntu 16.04 with PHP 7.1 from the Ondrej Sury Repository. Maybe try Ubuntu? 😁

@dterweij

Ok then compare some versions if there is a difference:

php-kolab-net-ldap3-1.0.3-1.el6.remi.noarch
php-gmp-7.1.0-1.el6.remi.x86_64
php-recode-7.1.0-1.el6.remi.x86_64
php-pear-DB-1.9.2-1.el6.remi.noarch
php-pdo-7.1.0-1.el6.remi.x86_64
php-snmp-7.1.0-1.el6.remi.x86_64
php-symfony-yaml-2.8.15-1.el6.remi.noarch
php-process-7.1.0-1.el6.remi.x86_64
php-soap-7.1.0-1.el6.remi.x86_64
php-pear-Net-Socket-1.0.14-1.el6.remi.noarch
php-pear-crypt-gpg-1.4.3-1.el6.remi.noarch
php-pspell-7.1.0-1.el6.remi.x86_64
php-pecl-weakref-0.3.3-1.el6.remi.7.1.x86_64
php-wikimedia-avro-1.7.7-1.el6.remi.noarch
php-fpm-7.1.0-1.el6.remi.x86_64
php-pear-Net-LDAP2-2.2.0-1.el6.remi.noarch
php-pear-Net-Sieve-1.3.4-4.el6.remi.noarch
php-intl-7.1.0-1.el6.remi.x86_64
php-json-7.1.0-1.el6.remi.x86_64
php-fedora-autoloader-0.2.1-2.el6.remi.noarch
php-pear-Mail-Mime-1.10.0-1.el6.remi.noarch
php-pecl-zip-1.13.5-2.el6.remi.7.1.x86_64
php-symfony-common-2.8.15-1.el6.remi.noarch
php-cli-7.1.0-1.el6.remi.x86_64
php-tcpdf-6.2.12-1.el6.remi.noarch
php-php-gettext-1.0.12-1.el6.remi.noarch
php-pear-Auth-SASL-1.0.6-1.el6.remi.noarch
php-udan11-sql-parser-3.4.14-1.el6.remi.noarch
php-pecl-yaml-2.0.0-2.el6.remi.7.1.x86_64
php-phpseclib-2.0.4-1.el6.remi.noarch
php-opcache-7.1.0-1.el6.remi.x86_64
php-bcmath-7.1.0-1.el6.remi.x86_64
php-pear-Net-SMTP-1.7.2-1.el6.remi.noarch
php-imap-7.1.0-1.el6.remi.x86_64
php-pecl-pthreads-3.1.7-0.4.20161111git959ab0f.el6.remi.7.1.x86_64
php-pear-1.10.1-8.el6.remi.noarch
php-common-7.1.0-1.el6.remi.x86_64
php-tidy-7.1.0-1.el6.remi.x86_64
php-pear-Net-IDNA2-0.1.1-6.el6.remi.noarch
php-symfony-class-loader-2.8.15-1.el6.remi.noarch
php-xml-7.1.0-1.el6.remi.x86_64
php-gd-7.1.0-1.el6.remi.x86_64
php-7.1.0-1.el6.remi.x86_64
php-mysqlnd-7.1.0-1.el6.remi.x86_64
php-ldap-7.1.0-1.el6.remi.x86_64
php-mcrypt-7.1.0-1.el6.remi.x86_64
php-pear-Console-CommandLine-1.2.2-1.el6.remi.noarch
php-pecl-geoip-1.1.1-3.el6.remi.7.1.x86_64
php-mbstring-7.1.0-1.el6.remi.x86_64
php-devel-7.1.0-1.el6.remi.x86_64
php-tcpdf-dejavu-sans-fonts-6.2.12-1.el6.remi.noarch

@dterweij

@dterweij

As alternative, just for this, I can alllow ssh access (with your pubkey) for you so you can check arround?

@GeoffreyDijkstra

That would make debugging a lot easier 😄
But in that case I suggest you sign up to spotweb2.slack.com and we can continue or live chats from there.
(and if that doesn’t work, to send me your email so I can add you)

@GeoffreyDijkstra

Next time please use the following code for extension version output, because it’s more readable:

<?php

$extensions = get_loaded_extensions();
foreach ($extensions as $extension) {
    echo str_pad($extension, 20, ' ', STR_PAD_RIGHT) . phpversion($extension) .                                                                                                                                                              "n";
}

My output:

Core                7.1.0-3+deb.sury.org~xenial+1
date                7.1.0-3+deb.sury.org~xenial+1
libxml              7.1.0-3+deb.sury.org~xenial+1
openssl             7.1.0-3+deb.sury.org~xenial+1
pcre                7.1.0-3+deb.sury.org~xenial+1
zlib                7.1.0-3+deb.sury.org~xenial+1
filter              7.1.0-3+deb.sury.org~xenial+1
hash                1.0
pcntl               7.1.0-3+deb.sury.org~xenial+1
Reflection          7.1.0-3+deb.sury.org~xenial+1
SPL                 7.1.0-3+deb.sury.org~xenial+1
session             7.1.0-3+deb.sury.org~xenial+1
standard            7.1.0-3+deb.sury.org~xenial+1
mysqlnd             mysqlnd 5.0.12-dev - 20150407 - $Id: d8daadaf41e3cd81d7c6ae9                                                                                                                                                             6c6091fd15b2c9382 $
PDO                 7.1.0-3+deb.sury.org~xenial+1
xml                 7.1.0-3+deb.sury.org~xenial+1
calendar            7.1.0-3+deb.sury.org~xenial+1
ctype               7.1.0-3+deb.sury.org~xenial+1
curl                7.1.0-3+deb.sury.org~xenial+1
dom                 20031129
mbstring            7.1.0-3+deb.sury.org~xenial+1
fileinfo            1.0.5
ftp                 7.1.0-3+deb.sury.org~xenial+1
gd                  7.1.0-3+deb.sury.org~xenial+1
gettext             7.1.0-3+deb.sury.org~xenial+1
iconv               7.1.0-3+deb.sury.org~xenial+1
igbinary            1.2.2-dev
imagick             3.4.3RC1
json                1.5.0
exif                1.4 $Id: 8bdc0c8f27c2c9dd1f7551f1f9fe3ab57a06a4b1 $
mcrypt              7.1.0-3+deb.sury.org~xenial+1
mongodb             1.2.0
mysqli              7.1.0-3+deb.sury.org~xenial+1
pdo_mysql           7.1.0-3+deb.sury.org~xenial+1
Phar                2.0.2
posix               7.1.0-3+deb.sury.org~xenial+1
readline            7.1.0-3+deb.sury.org~xenial+1
redis               3.0.0
shmop               7.1.0-3+deb.sury.org~xenial+1
SimpleXML           7.1.0-3+deb.sury.org~xenial+1
sockets             7.1.0-3+deb.sury.org~xenial+1
sysvmsg             7.1.0-3+deb.sury.org~xenial+1
sysvsem             7.1.0-3+deb.sury.org~xenial+1
sysvshm             7.1.0-3+deb.sury.org~xenial+1
tokenizer           7.1.0-3+deb.sury.org~xenial+1
wddx                7.1.0-3+deb.sury.org~xenial+1
xmlreader           7.1.0-3+deb.sury.org~xenial+1
xmlwriter           7.1.0-3+deb.sury.org~xenial+1
xsl                 7.1.0-3+deb.sury.org~xenial+1
zip                 1.13.5
Zend OPcache        7.1.0-3+deb.sury.org~xenial+1
xdebug              2.5.0

@GeoffreyDijkstra

@dterweij For anti spam I removed your message. (Inventation has been sent)
Github did have a PM function but they removed it, but if you really want to find out an email just look in commits 😁

@GeoffreyDijkstra

@mesa57 @Sweepr I looked into this, and as far as I can see now it’s related to the openssl version installed on @dterweij his machine. However the array thing is a real error, but the fix is already in the hotfix branch. So this will be merged and this issue will be closed.

@GeoffreyDijkstra

#246 It seems that there are more people with the openssl related errors in PHP 7.1, the only thing I now wonder, did this happen to him after adding the array fix into master or did he had it before…

@calvodioni

This is the solution to the error of no supported string or wrong element in php. if can not see the answer just click on preview. so you will see the answer.

<
2020-05-24

2018-11-08

Switched deprecated --set option to rector.php config.
Switched YAML to PHP configuration.

That’s right! PHP 5.6 and 7.0 are entering EOL — end of line life this December. Social networks, Slacks, Twitter, Reddit are full of it. Are you running PHP 7.1? Good, come next year when PHP 7.1 is eoling.

For the rest of you, what will you do when PHP will tell you the message in the title?

The most important info from PHP.net nowadays

You see all this social boom, your boss is scared by «no security support» and you finally have a go to upgrade your PHP code to PHP 7.1. You upgrade your PHP locally to see if everything works:

"Warning: count(): Parameter must be an array or an object that implements Countable in"
"Fatal error: Uncaught Error: [] operator not supported for strings in"
"Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Filter has a deprecated constructor in"
"Fatal error: Uncaught Error: Call to undefined function ereg() in"
"Fatal error: Cannot use empty list in"

You’re probably thinking lets jump to PHP 7.2, while you’re at it:

"Deprecated: The each() function is deprecated. This message will be suppressed on further calls in"

Don’t do it, always jump by minor versions — for both PHP and packages.

Actually, when you see a message — that’s a good sign. How else would you notice this?

// PHP 5.6-
list($a[], $a[]) = [1, 2];

// to get same result in PHP 7.0+
list($a[], $a[]) = array_reverse([1, 2])

True story — see 3v4l.org. The nice silent error just for you!

«I Got This»

But let’s say you know that «Deprecated: The each() function is deprecated. This message will be suppressed on further calls in» means refactor each each() usage to foreach().

(Often it’s more complicated, but keep this simple for now.)

Some cases are easy, if your variables are well-named:

while (list($key, $callback) = each($callbacks)) {
    // ...
}

foreach ($callbacks as $key => $callback) {
    // ...
}

But some… how would you change this one?

while (list($callback) = each($callbacks)) {
    // ...
}

foreach ($callbacks as $callback) {
    // ...
}

Are you sure? I think it should be like this:

foreach (array_keys($callbacks) as $callback) {
    // ...
}

See pull-request #661

Honestly, I’m not sure either. But I took time to test all possible each() combinations with list(), while() and do/while, put them into awesome 3v4l.org, wrote a bunch of tests and wrote tested rules for Rector.

"Fatal error: Uncaught Error: Call to undefined function ereg() in"

How Rector got into pure PHP Upgrades

At the PHP Asia Conference Rasmus Lerdorf spoke about upgrading PHP as a big problem. Much bigger than upgrading particular frameworks. Many WTF namings in PHP are just for BC sake. I struck me, that there is much more legacy PHP code in every company than there is framework-bound code.

I instantly created an issue at Rector, that deals with PHP 5.3 to 7.4 upgrades.
I went full-time on writing PHP upgrade rules — in the train, in the buss, in the plane (the best place to code actually, wonder why).

Today I’m proud to announce 7 new Rector levels that were not here a month ago:

use RectorCoreConfigurationOption;
use RectorSetValueObjectSetList;
use SymfonyComponentDependencyInjectionLoaderConfiguratorContainerConfigurator;
use RectorConfigRectorConfig;

return function (RectorConfig $rectorConfig): void {
    $rectorConfig->sets([
        SetList::PHP_54,
        SetList::PHP_55,
        SetList::PHP_56,
        SetList::PHP_70,
        SetList::PHP_71,
        SetList::PHP_72,
        SetList::PHP_73,
        SetList::PHP_74,
    ]);
};

I finally looked over my small framework bubble and learned a lot about problems of the world PHP community.

How to ereg Correctly?

One example for all:

See pull-request #661

"Fatal error: Uncaught Error: Call to undefined function ereg() in"

That’s easy, just add # around and change the function name, right?

-ereg('hi', $string);
+preg_match('#hi#', $string);

But what about?

ereg('[]-z]', $string);
ereg('^[a-z]+[.,][a-z]{3,}$', $string);

Don’t reinvent the wheel! Did you know that 8 years ago some guy wrote ereg → preg patterns converter? That some guy is Kang Seonghoon and helped hundreds if not thousands of people to not to give a fuck. Including me. Amazing work and I learned about it just by accidental googling. I wonder how many hidden gems are out there.

Take the Rector out, run it on your code, let it fix what it can and report the rest you had to do manually in the issues. Maybe it can be automated.
You’ll be helping each other developer, who upgrades the same PHP version you did. Imagine PHP version 5.3 would be shipped with set like this, covering 100 % of all changes. It’s up to us to make a brighter future now.

Happy coding!

This error comes when I updated my PHP version from PHP 5.6 to 7.4

Error Code:

Plugin could not be activated because it triggered a fatal error.

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/mysite/htdocs/wp-content/plugins/revslider/includes/operations.class.php on line 2339

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/mysite/htdocs/wp-content/plugins/revslider/includes/operations.class.php on line 2343

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/mysite/htdocs/wp-content/plugins/revslider/includes/output.class.php on line 3165

Fatal error: Uncaught Error: [] operator not supported for strings in /home/mysite/htdocs/wp-content/plugins/revslider/includes/framework/base-admin.class.php:71 Stack trace: #0 /home/mysite/htdocs/wp-content/plugins/revslider/admin/revslider-admin.class.php(572): RevSliderBaseAdmin::addMetaBox() #1 /home/mysite/htdocs/wp-content/plugins/revslider/admin/revslider-admin.class.php(73): RevSliderAdmin->addSliderMetaBox() #2 /home/mysite/htdocs/wp-content/plugins/revslider/admin/revslider-admin.class.php(44): RevSliderAdmin->init() #3 /home/mysite/htdocs/wp-content/plugins/revslider/revslider.php(171): RevSliderAdmin->__construct() #4 /home/mysite/htdocs/wp-admin/includes/plugin.php(2297): include('/opt/bitnami/ap...') #5 /home/mysite/htdocs/wp-admin/plugins.php(191): plugin_sandbox_scrape() #6 {main} thrown in /home/mysite/htdocs/wp-content/plugins/revslider/includes/framework/base-admin.class.php on line 71 
Older versions of WordPress plugin Revolution Slider by ThemePunch has this same deprecated PHP code, and throws an error:

To fix this error

Open file plugins/revslider/includes/framework/base-admin.class.php in you favourite editor

Go to line no 71

self::$arrMetaBoxes[] = $box;

self::$arrMetaBoxes[] = $box; 

Change it to

self::$arrMetaBoxes = array();
self::$arrMetaBoxes[] = $box;

self::$arrMetaBoxes = array(); 

The Array declaration with [] is not supported after PHP 7 +

Old Code:

$myarray[]; // Not work PHP 7.1 and +

Correct Code:

$myarray = array();

6elka1703

91 / 85 / 27

Регистрация: 29.10.2016

Сообщений: 928

1

02.02.2019, 21:39. Показов 8670. Ответов 4

Метки нет (Все метки)


Здравствуйте, делаю валидацию формы и если отправляю пустую форму то выдает ошибку

Fatal error: Uncaught Error: [] operator not supported for strings in C:OSPaneldomainsrepetitorreg.php:73 Stack trace: #0 {main} thrown in C:OSPaneldomainsrepetitorreg.php on line 73

. В чем проблема?

PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
$data = $_POST;
$errors = array();
if (isset($data['do_signup'])) {
    if (trim($data['name']) == '') {
        $errors[] = "Введите имя";
    } else if (preg_match("^[а-яА-Я]{2,10}^", $data['name'])) {
        $errors[] = "Неверный формат имени";
    }
 
    if (trim($data['phone']) == '') {
        $errors = "Введите номер телефона";
    } else if (preg_match("^((8|+7|+375)[- ]?)?((?d{3})?[- ]?)?[d- ]{7,10}$^", $data['phone'])) {
        $errors[] = "Неверный формат № телефона!";
    }
 
    if (trim($data['email']) == ''){
        $errors[] = "Неверный формат email!";
    }
    else if (preg_match('/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]
    +(.[a-z0-9-]+)*(.[a-z]{2,3})$/i', $data['email'])){
        $errors[] = "Неверный формат email!";
    }
 
    if($data['password2'] != $data['password']){
        $errors[] = "Пароли не совпадают";
    }
 
    if(empty($errors)){
 
    }
    else{
        echo '<div style="color: red">'.array_shift($errors).'</div>';
    }
 
}
?>

line 73 находится в этом условии

PHP
1
2
3
if (trim($data['email']) == ''){
        $errors[] = "Неверный формат email!";
    }

в этой строке

PHP
1
        $errors[] = "Неверный формат email!";

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Эксперт PHP

4839 / 3852 / 1598

Регистрация: 24.04.2014

Сообщений: 11,300

02.02.2019, 21:47

2

Лучший ответ Сообщение было отмечено 6elka1703 как решение

Решение

Цитата
Сообщение от 6elka1703
Посмотреть сообщение

$errors = «Введите номер телефона»;

errors не массив



1



91 / 85 / 27

Регистрация: 29.10.2016

Сообщений: 928

03.02.2019, 12:23

 [ТС]

3

Jewbacabra, спасибо, так и думал что просто совершил глупую ошибку, вот только интересно почему ошибку показывает не на той строке



0



Эксперт PHP

4839 / 3852 / 1598

Регистрация: 24.04.2014

Сообщений: 11,300

03.02.2019, 13:17

4

Цитата
Сообщение от 6elka1703
Посмотреть сообщение

вот только интересно почему ошибку показывает не на той строке

Где пытаешься обращаться со строкой как с массивом, там и показывает ошибку. Все правильно.



1



91 / 85 / 27

Регистрация: 29.10.2016

Сообщений: 928

03.02.2019, 17:23

 [ТС]

5

Jewbacabra, все понял, просто привык к C#, поэтому еще не до конца понимаю принцип работы с php



0



Понравилась статья? Поделить с друзьями:

Читайте также:

  • Fatal error uncaught error call to undefined method
  • Fatal error uncaught error call to undefined function split in
  • Fatal error uncaught error call to undefined function mysql connect in
  • Fatal error uncaught error call to undefined function imagecreatefromjpeg in
  • Fatal error uncaught error call to undefined function imagecreate

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии