WordPress.org

Forums

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

  1. hihitavec
    Member
    Posted 11 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 11 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 8 months ago #

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

  4. WillBontrager
    Member
    Plugin Author

    Posted 8 months 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

  • Insert PHP
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.