Skip to main content

Solution – WordPress and PHP 7.2 Error: PHP Warning Use of undefined constant

Submitted by admin on Fri, 12/10/2021 - 22:38
wordpress-error-undefined-constant
I recently upgraded one of my WordPress website to PHP version 7.2
Everything was working fine, but when I checked error_log file, I found many PHP error messages like:

PHP Warning: Use of undefined constant ‘DISALLOW_FILE_EDIT’ - assumed '‘DISALLOW_FILE_EDIT’' (this will throw an Error in a future version of PHP)
You can get similar error message for other WordPress constants on PHP 7.2 like:

PHP Warning: Use of undefined constant ‘DISABLE_WP_CRON’ - assumed '‘DISABLE_WP_CRON’' (this will throw an Error in a future version of PHP)

Solution

Solution is very simple. In your wordpress declaration code, put true inside quotation.
Example:


define( 'DISALLOW_FILE_EDIT', 'true' );


define( 'DISABLE_WP_CRON', 'true' );

I hope this article was helpful to you.

Category

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.