Title: Error in PHP snippet
Last modified: February 23, 2023

---

# Error in PHP snippet

 *  Resolved [Heiko Mitschke](https://wordpress.org/support/users/antares7/)
 * (@antares7)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/error-in-php-snippet/)
 * Hello!
 * I have been using this snippets for years. But now it breaks my site. I can not
   see the cause of the problem. In the snippet editor I got a white “x” on a red
   circle with the following message on the last line:
 *     ```wp-block-code
       e is undefined
       ```
   
 * The code of the snippet is:
 *     ```wp-block-code
       if(strpos({mehrbezeichnung}, 'keine' ) === false)
       {
       echo '
       	<div class="termin grid-container grid-parent">
       		<div class="datum mobile-grid-100 tablet-grid-20 grid-20">{datum}</div>
       		<div class="beschreibung mobile-grid-100 tablet-grid-80 grid-80">
       		<span class="titel">{titel}</span><span class="zusatz-titel">{zusatztitel}</span>
       		[showhide type="{mehrbezeichnung}" more_text="Mehr Informationen..." less_text="Weniger Informationen..."]{content}[/showhide]
       		</div>		
       	</div>';
       }
       else {
       echo '
       	<div class="termin grid-container grid-parent">
       		<div class="datum mobile-grid-100 tablet-grid-20 grid-20">{datum}</div>
       		<div class="beschreibung mobile-grid-100 tablet-grid-80 grid-80">
       			<span class="titel">{titel}</span><span class="zusatz-titel">{zusatztitel}</span>
       		</div>
       	</div>';
       }
       ```
   
 * On the frontend I got this error message:
 *     ```wp-block-code
       Fatal error: Uncaught Error: Undefined constant "keine" in .../PostSnippets/Shortcode.php(110) : eval()'d code:1 Stack trace: #0 .../PostSnippets/Shortcode.php(110): eval() #1 .../PostSnippets/Shortcode.php(63): PostSnippets\Shortcode::phpEval('if(strpos(keine...') #2 .../PostSnippets/Shortcode.php(29): PostSnippets\Shortcode::evaluateSnippet(Array, Array, '') #3 .../wp-includes/shortcodes.php(355): PostSnippets\Shortcode->PostSnippets\{closure}(Array, '', 'Termin') #4 [internal function]: do_shortcode_tag(Array) #5 .../wp-includes/shortcodes.php(227): preg_replace_callback('/\\[(\\[?)(Termin...', 'do_shortcode_ta...', '<h2>Februar</h2...') #6 .../wp-includes/class-wp-hook.php(308): do_shortcode('<h2>Februar</h2...') #7 .../wp-includes/plugin.php(205): WP_Hook->apply_filters('<h2>Februar</h2...', Array) #8 .../wp-includes/post-template.php(255): apply_filters('the_content', '<!-- wp:heading...') #9 .../wp-content/themes/generatepress/content-page.php(73): the_content() #10 .../wp-includes/template.php(785): require('/var/www/web296...') #11 .../wp-includes/template.php(718): load_template('/var/www/web296...', false, Array) #12 .../wp-includes/general-template.php(204): locate_template(Array, true, false, Array) #13 .../wp-content/themes/generatepress/inc/theme-functions.php(568): get_template_part('content', 'page') #14 .../wp-content/themes/generatepress/page.php(34): generate_do_template_part('page') #15 .../wp-includes/template-loader.php(106): include('/var/www/web296...') #16 .../wp-blog-header.php(19): require_once('/var/www/web296...') #17 .../index.php(17): require('/var/www/web296...') #18 {main} thrown in .../PostSnippets/Shortcode.php(110) : eval()'d code on line 1
       ```
   
 * Can anyone help with this problem? I would really would be glad if someone could
   solve the problem.
 * I use the latest plugin version and PHP 8.0.
 * Thanks in advance!
   Heiko
    -  This topic was modified 3 years, 3 months ago by [Heiko Mitschke](https://wordpress.org/support/users/antares7/).
    -  This topic was modified 3 years, 3 months ago by [Heiko Mitschke](https://wordpress.org/support/users/antares7/).

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

 *  Thread Starter [Heiko Mitschke](https://wordpress.org/support/users/antares7/)
 * (@antares7)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/error-in-php-snippet/#post-16500273)
 * The two blocks on its own work. The problem only seems to occur if I use the 
   if-statement. Is there a notation problem?
 *  Thread Starter [Heiko Mitschke](https://wordpress.org/support/users/antares7/)
 * (@antares7)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/error-in-php-snippet/#post-16500346)
 * Now I created two separate snippets that do work properly…

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

The topic ‘Error in PHP snippet’ is closed to new replies.

 * ![](https://ps.w.org/post-snippets/assets/icon-128x128.gif?rev=2545587)
 * [Post Snippets - Custom WordPress Code Snippets Customizer](https://wordpress.org/plugins/post-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/post-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-snippets/reviews/)

 * 2 replies
 * 1 participant
 * Last reply from: [Heiko Mitschke](https://wordpress.org/support/users/antares7/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/error-in-php-snippet/#post-16500346)
 * Status: resolved