WordPress.org

Ready to get started?Download WordPress

Forums

Insert PHP
[resolved] Or in if statement (4 posts)

  1. hihitavec
    Member
    Posted 4 months ago #

    I have problem with or in if statement. If I use this code:

    $var = 1;
    $var2 = 5;
    if($var == 3 || $var2 == 5){
      echo "works";
    }

    Then it will display works, but at the end there will also display all code.

    https://wordpress.org/plugins/insert-php/

  2. WillBontrager
    Member
    Plugin Author

    Posted 4 months ago #

    hihitavec, Testing it on my site, if find the vertical bar or ("||") is causing it.

    Insert PHP runs the code by putting it into an eval(). It seems "||" and "|" need special handling and I don't have the answer immediately.

    If you can use "or" instead of "||" then it should work.

    Will

  3. WillBontrager
    Member
    Plugin Author

    Posted 1 month ago #

    Because there has been no response, I'm assuming the original poster resolved the issue.

  4. WillBontrager
    Member
    Plugin Author

    Posted 1 month ago #

    Hmm, forgot to check the "Mark this topic as resolved" box.

    So, this extra post to get the thread marked resolved.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.