Title: T_VARIABLE error
Last modified: August 22, 2016

---

# T_VARIABLE error

 *  Resolved [Rodrigo Gomes](https://wordpress.org/support/users/konoma/)
 * (@konoma)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/t_variable-error-1/)
 * Hello! I’m trying to make a test in a post, but I get the message:
 * “PHP Parse error: syntax error, unexpected T_VARIABLE in E:\home\barreirainformatica\
   Web\novo\wp-content\plugins\insert-php\insert_php.php(48) : eval()’d code on 
   line 11”
 * Did I type something wrong? I’m not yet used to PHP anyway.
    This is what I’m
   trying to do:
 *     ```
       [insert_php]
   
       $time = date("H"); 
   
       if( $time >= 17 && $time < 19 )
   
           $img_name = 'http://www.bistec.com.br/novo/wp-content/uploads/2014/11/Sweda-Apas-g-2010-shop_166110151912930.jpg';
   
       else( $time >= 19 && $time < 6 )
   
           $img_name = 'http://www.bistec.com.br/novo/wp-content/uploads/2014/11/padarias560.jpg';
   
       [/insert_php]
   
       <style>
           .my-class{background-image:url('[insert_php] echo $img_name; [/insert_php]');}
       </style>
   
       <div class="my-class">Aproveite que o S@T Sweda - Soluções em Automação Comercial foi homologado e assista a palestra do 3º Fórum BISTEC sobre o produto.</div>
       ```
   
 * THanks in advance.
 * [https://wordpress.org/plugins/insert-php/](https://wordpress.org/plugins/insert-php/)

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

 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/t_variable-error-1/#post-5720108)
 * Hi Rodrigo Gomes,
 * The PHP code between the [insert_php] and [/insert_php] tags must be complete
   in itself. There is no outside scope.
 * This page is handy for reference about that and other limitations you may encounter:
 * [http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php](http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php)
 * Perhaps a solution to the issue you presented is to let the PHP code echo the
   code for the CSS style. Something like this:
 *     ```
       [insert_php]
       $time = date("H");
       if( $time >= 17 && $time < 19 )
          $img_name = 'http://www.bistec.com.br/novo/wp-content/uploads/2014/11/Sweda-Apas-g-2010-shop_166110151912930.jpg';
       else( $time >= 19 && $time < 6 )
          $img_name = 'http://www.bistec.com.br/novo/wp-content/uploads/2014/11/padarias560.jpg';
       echo "<style>.my-class{background-image:url('$img_name');}</style>";
       [/insert_php]
   
       <div class="my-class">Aproveite que o S@T Sweda - Soluções em Automação Comercial foi homologado e assista a palestra do 3º Fórum BISTEC sobre o produto.</div>
       ```
   
 * Will
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/t_variable-error-1/#post-5720168)
 * Gratuitous post to mark topic resolved.
 *  Thread Starter [Rodrigo Gomes](https://wordpress.org/support/users/konoma/)
 * (@konoma)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/t_variable-error-1/#post-5720169)
 * Sorry to delay answering the message. I still couldn’t test the method, but I
   thank you for the quick answer, and for the link. If I need more information,
   I’ll get in touch. Thanks again!

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

The topic ‘T_VARIABLE error’ is closed to new replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3523853)
 * [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/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * 3 replies
 * 2 participants
 * Last reply from: [Rodrigo Gomes](https://wordpress.org/support/users/konoma/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/t_variable-error-1/#post-5720169)
 * Status: resolved