PHP Lamba-style function code throwing a slew of of undefined variable errors -


i'm using php create_function make lamba-style function contents defined heredoc style string. fine until moved code hostgator account. hostgator environment causing function fail.

it looks heredoc working fine, , create_function seems executing. when function gets called, dumps ton of errors claiming every local variable undefined! i'm baffled! seen before? here's code:

$func_code = <<<eot extract( shortcode_atts( array('style' => '','class' => '', 'id' => '', 'gutter' => 'm'), $atts ) ); $col_and_gutter = isset($gutter) ? 'needle-' . $gutter : 'needle-m';  switch ($gutter) {     case 'ew': $gutter = 'col-extra-wide-gutter'; break;     case 'w': $gutter = 'col-wide-gutter'; break;     case 'm': $gutter = 'col-med-gutter'; break;     case 'n': $gutter = 'col-narrow-gutter'; break;     case 'none': $gutter = 'col-no-gutter'; break; }  if ($id != '') $id = 'id="' . $id . '"'; if ($style != '') $style = 'style="' . $style . '"'; $returnval =  '<div ' . $id . ' ' . $style . ' class="col-responsive ' . $col_and_gutter . " " . $gutter . " " . $class . '">';  $returnval .= '<div class="g1"><div class="g2"><div class="g3">' . do_shortcode($content) . '</div></div></div>'; $returnval .= '</div>'; return $returnval; eot;              $func_code = str_replace('needle', $shortcode, $func_code); $func_handle = create_function('$atts,$content', $func_code);  add_shortcode($shortcode, $func_handle); add_shortcode($shortcode . '-n', $func_handle); add_shortcode($shortcode . '-nn', $func_handle); 

here error output:

notice: undefined variable: atts in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 129

notice: undefined variable: col_and_gutter in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 129

notice: undefined variable: gutter in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 129

notice: undefined variable: gutter in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 131

notice: undefined variable: gutter in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 132

notice: undefined variable: gutter in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 133

notice: undefined variable: gutter in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 134

notice: undefined variable: gutter in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 135

notice: undefined variable: gutter in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 136

notice: undefined variable: gutter in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 139

notice: undefined variable: id in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 139

notice: undefined variable: id in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 139

notice: undefined variable: id in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 140

notice: undefined variable: style in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 140

notice: undefined variable: style in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 140

notice: undefined variable: style in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 141

notice: undefined variable: returnval in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 141

notice: undefined variable: id in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 141

notice: undefined variable: style in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 141

notice: undefined variable: col_and_gutter in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 141

notice: undefined variable: gutter in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 141

notice: undefined variable: class in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 142

notice: undefined variable: returnval in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 142

notice: undefined variable: content in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 143

notice: undefined variable: returnval in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 144

notice: undefined variable: returnval in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php on line 145

parse error: syntax error, unexpected ')' in /home3/ade207/public_html/wp-content/themes/armstrongparent/lib/shortcodes.php(148) : runtime-created function on line 1

@passerby. thanks, tipped me off problem.

all $variables empty blank areas!! because heredoc automatic variable substitution. person might wondering how come worked fine in other environments: godaddy , linode vps not on hostgator...

the reason broke on hostgator because heredoc line nowdoc when first uploaded it. threw error changed heredoc removing single quotes. wasn't thinking @ , stupidly didn't realize kicks in variable substitution variables replaced null strings instead of staying string literals function code.

evidentally, hostgator isn't running php 5.3 or later why nowdoc doesn't work. , means need modify script more backward compatible anyway. might have escape variables ugly look.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -