Title: PHP Parse error: syntax error, unexpected &#8216;?&#8217;, expecting variable (T_VARIABLE)
Last modified: May 28, 2022

---

# PHP Parse error: syntax error, unexpected ‘?’, expecting variable (T_VARIABLE)

 *  Resolved [0815martin](https://wordpress.org/support/users/0815martin/)
 * (@0815martin)
 * [4 years ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-expecting-variable-t_variable/)
 * I get this error since mid of May:
    PHP Parse error: syntax error, unexpected‘?’,
   expecting variable (T_VARIABLE) in /home/www/<DOMAIN>/WordPress/wp-content/plugins/
   woocommerce/vendor/symfony/polyfill-php80/bootstrap.php on line 29
 * The PHP version on the server is 7.4
 * I tried to fix it by deleting the bold and italic questionmarks in the code below:
 * function str_contains(**_?_**string $haystack, **_?_**string $needle): bool {
   return p\Php80::str_contains($haystack ?? ”, $needle ?? ”); }
 * function str_ends_with(**_?_**string $haystack, **_?_**string $needle): bool {
   return p\Php80::str_ends_with($haystack ?? ”, $needle ?? ”); }
 * That helped with this individual error but then a next error showed up:
    PHP 
   Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (
   T_VARIABLE) in /home/www/<DOMAIN>/WordPress/wp-content/plugins/woocommerce/src/
   Internal/DependencyManagement/Definition.php on line 18
 * I did not try to fix this one.
 * What should I do here?
    (Switching to PHP 8.0 does not work for my site for unknown
   reason)
 * The system status report does not tell any errors
 *  Martin
    -  This topic was modified 4 years ago by [0815martin](https://wordpress.org/support/users/0815martin/).
    -  This topic was modified 4 years ago by [0815martin](https://wordpress.org/support/users/0815martin/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-parse-error-syntax-error-unexpected-expecting-variable-t_variable%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Thread Starter [0815martin](https://wordpress.org/support/users/0815martin/)
 * (@0815martin)
 * [4 years ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-expecting-variable-t_variable/#post-15687127)
 * The cron job (to run wp-cron.php) is scheduled by the system and I found now 
   it used PHP version 7.0 only.
 * In the cron configuration, now I call explicitly the php7.4 version and it seems
   the error is gone.
 *  Plugin Support [Tamirat B. (a11n)](https://wordpress.org/support/users/tamirat22/)
 * (@tamirat22)
 * [4 years ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-expecting-variable-t_variable/#post-15687306)
 * Hello [@0815martin](https://wordpress.org/support/users/0815martin/)!
 * > In the cron configuration, now I call explicitly the php7.4 version and it 
   > seems the error is gone.
 * Glad to hear it and thanks for letting us know!
 * Refer to the compatibility matrix here for more insight: [https://woocommerce.com/document/update-php-wordpress/](https://woocommerce.com/document/update-php-wordpress/)
 * If you have any further questions regarding WooCommerce Core, I recommend creating
   a new thread🙂

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

The topic ‘PHP Parse error: syntax error, unexpected ‘?’, expecting variable (T_VARIABLE)’
is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

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

 * 2 replies
 * 2 participants
 * Last reply from: [Tamirat B. (a11n)](https://wordpress.org/support/users/tamirat22/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-expecting-variable-t_variable/#post-15687306)
 * Status: resolved