• Resolved Flankerator

    (@flankerator)


    Hello Alex,
    Very nice plugin, simple and does the job well.

    When having multiples php instances that share same variable, i noticed that I have to include same variable in each instance, so basically when updating variables, I would have to do it in all instances every time.

    Is there a way to have one instance where I update the variable and then it shares it across all instances that are posted on same page?

    Example:
    <?php
    //master update here
    if($instance==”1″)
    {
    $date1=”2018-08-01″;
    $date2=”2017-11-01″;
    }
    if($instance==”2″)
    {
    echo $date1;
    }
    if($instance==”3″)
    {
    echo $date2;
    }

    ?>
    Many thanks.

    Naim

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Alex

    (@alexander_fuchs)

    Hi Naim,

    this should already work. You can just put rhe variable assignment outside of the instance.

    Like this:

    <?php

    //master assignment here
    $text = ‘Hello word’;
    if($instance == “1”)
    {
    echo $text;
    }

    Let me know if it works for you.

    Thread Starter Flankerator

    (@flankerator)

    It worked, thanks Alex!

    the UI box is tiny to edit long code but i could copy paste back and forth between wp and a notepad.

    Thanks
    Naim

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shared variables’ is closed to new replies.