• Hi,
    I found mistakes on writing php
    in shortcodes.php on line 1453
    $post = ( empty( $post ) || empty( $post->$atts[‘field’] ) ) ? $atts[‘default’] : $post->$atts[‘field’];

    $post->$atts[‘field’] must be write like that $post->{$atts[‘field’]}

    see http://php.net/manual/en/language.oop5.php,
    User Contributed Notes , 53 farzan at ifarzan dot com

    Good plugin, thank’s

Viewing 6 replies - 1 through 6 (of 6 total)
  • Please tell me, there is a problem after the transfer to another server, is now shortcode in the widget pops up with an error, “Notice: Array to string conversion in /var/www/html/wp-content/plugins/shortcodes-ultimate/inc/core/shortcodes.php on line 1452” tried to disable all the widgets may conflict, well, the result is the same mistake, tell me what can be done?

    my WordPress 4.7.2 (php7.0, apache/2.4.18)

    Thanks!

    I tried to put the same thing only on the server where php5, all works, compatibility plugin is clearly a problem with php7 !! I hope to fix soon

    Thread Starter lorick

    (@lorick)

    Hi,
    When debug is true, I get this message

    Notice: Array to string conversion in ../wp-content/plugins/shortcodes-ultimate/inc/core/shortcodes.php on line 1455

    It’s not about php version but just the way of writing : brackets is missing

    $post->$atts[‘field’] must be write like that $post->{$atts[‘field’]}

    see http://php.net/manual/en/language.oop5.php,
    User Contributed Notes , 56 farzan at ifarzan dot com (12 years ago)

    • This reply was modified 9 years, 3 months ago by lorick.

    $post->{$atts[‘field’]} – I tried to change the result did not give!

    Thread Starter lorick

    (@lorick)

    Sorry, my english is not so good !

    it’s just the good way to write object elements when then are array or function
    See examples below from User Contributed Notes (php Manual) :

    PHP 5 is very very flexible in accessing member variables and member functions. These access methods maybe look unusual and unnecessary at first glance; but they are very useful sometimes; specially when you work with SimpleXML classes and objects. I have posted a similar comment in SimpleXML function reference section, but this one is more comprehensive.

    I use the following class as reference for all examples:

    <?php
    class Foo {
    public $aMemberVar = ‘aMemberVar Member Variable’;
    public $aFuncName = ‘aMemberFunc’;

    function aMemberFunc() {
    print ‘Inside aMemberFunc()‘;
    }
    }

    $foo = new Foo;
    ?>

    You can access member variables in an object using another variable as name:

    <?php
    $element = ‘aMemberVar’;
    print $foo->$element; // prints “aMemberVar Member Variable”
    ?>

    or use functions:

    <?php
    function getVarName()
    { return ‘aMemberVar’; }

    print $foo->{getVarName()}; // prints “aMemberVar Member Variable”
    ?>

    Important Note: You must surround function name with { and } or PHP would think you are calling a member function of object “foo”.

    you can use a constant or literal as well:

    <?php
    define(MY_CONSTANT, ‘aMemberVar’);
    print $foo->{MY_CONSTANT}; // Prints “aMemberVar Member Variable”
    print $foo->{‘aMemberVar’}; // Prints “aMemberVar Member Variable”
    ?>

    You can use members of other objects as well:

    <?php
    print $foo->{$otherObj->var};
    print $foo->{$otherObj->func()};
    ?>

    You can use mathods above to access member functions as well:

    <?php
    print $foo->{‘aMemberFunc’}(); // Prints “Inside aMemberFunc()
    print $foo->{$foo->aFuncName}(); // Prints “Inside aMemberFunc()
    ?>

    same problem on PHP7.1

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Notice: Array to string conversion in /shortcodes.php on line 1453’ is closed to new replies.