Title: Inline PHP If/Elseif/Else statement Help
Last modified: December 16, 2018

---

# Inline PHP If/Elseif/Else statement Help

 *  Resolved [geowil](https://wordpress.org/support/users/geowil/)
 * (@geowil)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/inline-php-if-elseif-else-statement-help/)
 * Hello, I am attempting to use your plugin to inject some PHP/HTML coding into
   a page on our WP site but I am running into the following error when trying to
   view the page:
 * > Notice: Undefined index: err in /var/www/html/wp-content/plugins/insert-php/
   > includes/shortcodes.php(66) : eval()’d code on line 1
   > Fatal error: Uncaught Error: Call to undefined function IsEmpty() in /var/www/
   > html/wp-content/plugins/insert-php/includes/shortcodes.php(66) : eval()’d code:
   > 3 Stack trace: #0 /var/www/html/wp-content/plugins/insert-php/includes/shortcodes.
   > php(66): eval() #1 /var/www/html/wp-content/plugins/insert-php/libs/factory/
   > shortcodes/shortcode.class.php(287): WINP_SnippetShortcode->html(Array, ”) #
   > 2 /var/www/html/wp-content/plugins/insert-php/libs/factory/shortcodes/shortcodes.
   > php(97): Wbcr_FactoryShortcodes324_Shortcode->render(Array, ”) #3 /var/www/
   > html/wp-includes/shortcodes.php(319): Wbcr_FactoryShortcodes324_ShortcodeManager-
   > >__call(‘shortcode_WINP_…’, Array) #4 [internal function]: do_shortcode_tag(
   > Array) #5 /var/www/html/wp-includes/shortcodes.php(197): preg_replace_callback(‘/\\[(\\[?)(
   > wbcr_p…’, ‘do_shortcode_ta…’, ‘<style type=”te…’) #6 /var/www/html/wp-content/
   > plugins/js_composer_theme/include/helpers/helpers.php(236): do_shortcode(‘<
   > style type=”te…’) #7 /var/www/html/wp-content/plugins/js_composer_theme/inclu
   > in /var/www/html/wp-content/plugins/insert-php/includes/shortcodes.php(66) :
   > eval()’d code on line 3
 * Have you created the parser to handle inline php if-ing correctly? Here is my
   snippet:
 *     ```
       if ($_GET['err'] === "LoginErr") : ?>
           <label style="display: block; font-size: 18px; font-weight: bold;">Username or password incorrect, or the username was not found.  Please try again or ask for assistance.</label>
       <?php elseif (!IsEmpty($_GET['err'])) : ?>
           <label style="display: block; font-size: 18px; font-weight: bold;">An unexpected error has happened.  Please notify the instructor.<br/><br/>  Error Message: <?php echo $_GET['err']; ?></label>
       <?php else : ?>
       <?php endif;
       ```
   
 * If I drop this into a non-Wordpress page and add in the first opening and last
   closing tags it works.
    -  This topic was modified 7 years, 3 months ago by [geowil](https://wordpress.org/support/users/geowil/).
    -  This topic was modified 7 years, 3 months ago by [geowil](https://wordpress.org/support/users/geowil/).
    -  This topic was modified 7 years, 3 months ago by [geowil](https://wordpress.org/support/users/geowil/).
    -  This topic was modified 7 years, 3 months ago by [geowil](https://wordpress.org/support/users/geowil/).

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

 *  Thread Starter [geowil](https://wordpress.org/support/users/geowil/)
 * (@geowil)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/inline-php-if-elseif-else-statement-help/#post-10994111)
 * Nevermind, I go it.
 * It occurred to me after posting that if WordPress does stupid parsing, it is 
   not intelligent (HUGE design flaw if you ask me), it would cause this. It looks
   for the parameter without checking if it actually exists first which is why it
   was throwing out that err did not exist.
 * So I have changed my code to this and it is working perfectly.
 *     ```
       if (isSet($_GET['err']) && !Empty($_GET['err']) && $_GET['err'] === "LoginErr") : ?>
           <label style="display: block; font-size: 18px; font-weight: bold;">Username or password incorrect, or the username was not found.  Please try again or ask for assistance.</label>
       <?php elseif (isSet($_GET['err']) && !Empty($_GET['err'])) : ?>
           <label style="display: block; font-size: 18px; font-weight: bold;">An unexpected error has happened.  Please notify the instructor.<br/><br/>  Error Message: <?php echo $_GET['err']; ?></label>
       <?php else : ?>
       <?php endif; 
       ```
   
 * Great plugin to add something that WordPress should have by default.
    -  This reply was modified 7 years, 3 months ago by [geowil](https://wordpress.org/support/users/geowil/).
    -  This reply was modified 7 years, 3 months ago by [geowil](https://wordpress.org/support/users/geowil/).
    -  This reply was modified 7 years, 3 months ago by [geowil](https://wordpress.org/support/users/geowil/).
 *  [Kirill [Webcraftic support]](https://wordpress.org/support/users/kirillgru/)
 * (@kirillgru)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/inline-php-if-elseif-else-statement-help/#post-11002117)
 * Hi
    I’m glad you figured it out.
 * Best regards

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

The topic ‘Inline PHP If/Elseif/Else statement Help’ is closed to new replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3475630)
 * [Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts](https://wordpress.org/plugins/insert-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Kirill [Webcraftic support]](https://wordpress.org/support/users/kirillgru/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/inline-php-if-elseif-else-statement-help/#post-11002117)
 * Status: resolved