Title: PHP code and blade files
Last modified: October 21, 2024

---

# PHP code and blade files

 *  Resolved [webspilka](https://wordpress.org/support/users/webspilka/)
 * (@webspilka)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/php-code-and-blade-files/)
 * Hi I use
    - loco translate v 2.6.11
    - theme based on [sage theme](https://github.com/roots/sage)
 * Еverything was working fine but today i found a problem. 
   If I add php code in
   my *.blade.php files:
 *     ```wp-block-code
       <?php// Loco translate see this php scope$loco_works_for_it = __('Loco Works for this', 'vgstudio');?><span class="share__text">{{ __('Loco dont see this', 'vgstudio') }}</span>
       ```
   
 * If I delete <?php ?> block from my file:
 *     ```wp-block-code
       <span class="share__text">{{ __('Loco Works for this', 'vgstudio') }}</span>
       ```
   
 * Can I use php and blade at the same time in one file ?

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

 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/php-code-and-blade-files/#post-18086605)
 * Currently, no. The Blade extractor in Loco Translate is a bit of a workaround,
   and assumes the file is all non-PHP code.
 * It starts by adding its own `<?php` tag to the beginning of the stream, and then
   uses the PHP tokenizer to parse out the function calls. It doesn’t try to switch
   between PHP and non-PHP as it works through the file. I guess it should, but 
   it doesn’t. I don’t use Blade, so I wasn’t aware this was a problem.
 *  Thread Starter [webspilka](https://wordpress.org/support/users/webspilka/)
 * (@webspilka)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/php-code-and-blade-files/#post-18086792)
 * Thank you for your prompt response. I understand what the problem is now, it 
   can be easily bypassed by changing the code to the following
 *     ```wp-block-code
       @php$loco_works = __('Loco Works for this', 'vgstudio');@endphp<span class="share__text">  {{ __('and now Loco Works for this to', 'vgstudio') }}</span>
       ```
   
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/php-code-and-blade-files/#post-18086800)
 * Great. Saves me some work.
 * Thanks for posting your solution

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

The topic ‘PHP code and blade files’ is closed to new replies.

 * ![](https://ps.w.org/loco-translate/assets/icon-256x256.png?rev=1000676)
 * [Loco Translate](https://wordpress.org/plugins/loco-translate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/loco-translate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/loco-translate/)
 * [Active Topics](https://wordpress.org/support/plugin/loco-translate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/loco-translate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/loco-translate/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * Last activity: [1 year, 7 months ago](https://wordpress.org/support/topic/php-code-and-blade-files/#post-18086800)
 * Status: resolved