Title: PHP 8.0 compatibility error
Last modified: September 27, 2022

---

# PHP 8.0 compatibility error

 *  Resolved [Marty](https://wordpress.org/support/users/bozzmedia/)
 * (@bozzmedia)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/)
 * The following ended up in my debug.log:
 * > PHP Deprecated: Invalid characters passed for attempted conversion, these have
   > been ignored in /home/redacted/public_html/wp-content/plugins/amp/src/ReaderThemeSupportFeatures.
   > php on line 375

Viewing 15 replies - 1 through 15 (of 20 total)

1 [2](https://wordpress.org/support/topic/php-8-0-compatibility-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/php-8-0-compatibility-error/page/2/?output_format=md)

 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16051295)
 * Hello [@bozzmedia](https://wordpress.org/support/users/bozzmedia/)
 * Thank you for contacting us, I think you also faced [similar issue](https://wordpress.org/support/topic/php-deprecated-invalid-characters-passed-for-attempted-conversion-4/)
   when you are using PHP 7.4.0 so I doubt that this is related to the PHP version,
   the issue might be related to your hex color code.
 * To make sure we also tested it with PHP 8.0.21 and we didn’t get any warning.
 * To debug the issue further Can you please log in as Admin and visit
    Appearance-
   > AMP -> Colors & Dark Mode, Copy the color code and send it back to us by replying
   to this thread
 * I hope this helps!
 *  Thread Starter [Marty](https://wordpress.org/support/users/bozzmedia/)
 * (@bozzmedia)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16052426)
 * Thank you [@milindmore22](https://wordpress.org/support/users/milindmore22/) 
   for your help here and in my other thread that I completely forgot about (sorry!).
 * I am using Reader Mode with the AMP Legacy theme. I checked the color settings
   and the only thing that I noticed was for one color I was using an abbreviated
   hex code `#fff`. While I figure that is still a compliant syntax I changed it
   to `#ffffff` — let’s see if that does the trick.
 *  Thread Starter [Marty](https://wordpress.org/support/users/bozzmedia/)
 * (@bozzmedia)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16052760)
 * So far, no impact. More lines of the error here indicating it may be several 
   items?
 *     ```
       [28-Sep-2022 19:34:21 UTC] PHP Deprecated:  Invalid characters passed for attempted conversion, these have been ignored in /home/redacted/public_html/wp-content/plugins/amp/src/ReaderThemeSupportFeatures.php on line 375
       [28-Sep-2022 19:34:21 UTC] PHP Deprecated:  Invalid characters passed for attempted conversion, these have been ignored in /home/redacted/public_html/wp-content/plugins/amp/src/ReaderThemeSupportFeatures.php on line 376
       [28-Sep-2022 19:34:21 UTC] PHP Deprecated:  Invalid characters passed for attempted conversion, these have been ignored in /home/redacted/public_html/wp-content/plugins/amp/src/ReaderThemeSupportFeatures.php on line 377
       ```
   
 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16054987)
 * Hello [@bozzmedia](https://wordpress.org/support/users/bozzmedia/)
 * Can you please send your site health information using [this form](https://forms.gle/gJL8MZXHGsAFFaBYA)
   so we can try to re-create your site environment and debug the issue
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16055958)
 * This is the code in question: [https://github.com/ampproject/amp-wp/blob/a373ac8f65f26ee7df7313ff5d734b5704781ab0/src/ReaderThemeSupportFeatures.php#L366-L380](https://github.com/ampproject/amp-wp/blob/a373ac8f65f26ee7df7313ff5d734b5704781ab0/src/ReaderThemeSupportFeatures.php#L366-L380)
 * The code being complained about is:
 *     ```
       $red   = hexdec( substr( $hex, 0, 2 ) );
       $green = hexdec( substr( $hex, 2, 2 ) );
       $blue  = hexdec( substr( $hex, 4, 2 ) );
       ```
   
 * No error occurs when `$hex` is `ffffff`: [https://3v4l.org/VTmvu](https://3v4l.org/VTmvu)
 * However, if `$hex` is `#ffffff` then the reported issue occurs: [https://3v4l.org/RNVnF](https://3v4l.org/RNVnF)
 * Nevertheless, this `#` should not be present because of [this code](https://github.com/ampproject/amp-wp/blob/a373ac8f65f26ee7df7313ff5d734b5704781ab0/src/ReaderThemeSupportFeatures.php#L366-L367):
 *     ```
       // Remove the "#" symbol from the beginning of the color.
       $hex = ltrim( $hex, '#' );
       ```
   
 * So what specifically is `$hex` for you as being passed into your `get_relative_luminance_from_hex`
   method?
    -  This reply was modified 3 years, 8 months ago by [Weston Ruter](https://wordpress.org/support/users/westonruter/).
 *  Thread Starter [Marty](https://wordpress.org/support/users/bozzmedia/)
 * (@bozzmedia)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16065994)
 * I have hex codes complete with the # symbol in the Customizer > AMP settings.
 * I will see if removing those helps. Thanks for the insight!
 *  Thread Starter [Marty](https://wordpress.org/support/users/bozzmedia/)
 * (@bozzmedia)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16066170)
 * OK, I went to run through this again and instead of manually pasting in the hex
   code I used the color picker. It adds the # symbol to the field automatically.
 * I’m not sure how to debug what the actual $hex values are, but happy to try if
   you can point me in the right direction. Thanks again.
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16066455)
 * I still don’t see how including or omitting the `#` would make any difference
   because the code is doing `ltrim( $hex, '#' )`, which means any initial `#` will
   be stripped.
 *  Thread Starter [Marty](https://wordpress.org/support/users/bozzmedia/)
 * (@bozzmedia)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16066468)
 * Here is the frontend html from the customizer, does this help? Let me know how
   else I can help debug.
 *     ```
       <ul class="customize-pane-child accordion-section-content accordion-section control-section control-section-default open" id="sub-accordion-section-amp_design">
       				<li class="customize-section-description-container section-meta ">
       					<div class="customize-section-title">
       						<button class="customize-section-back" tabindex="0">
       							<span class="screen-reader-text">Back</span>
       						</button>
       						<h3>
       							<span class="customize-action">
       								Customizing ▸ AMP
       							</span>
       							Design
       						</h3>
   
   
       						<div class="customize-control-notifications-container"><ul><li class="notice notice-info  " data-code="amp_unavailable" data-type="info">
       				<div class="notification-message">
       					AMP is not available for the page currently being previewed.
   
       						<a href="https://redacted.com/amp">Navigate to an AMP compatible page</a>
   
       				</div>
       			</li></ul></div>
       					</div>
   
   
       				</li>
       			<li id="customize-control-amp_header_color" class="customize-control customize-control-color">
   
   
       			<span class="customize-control-title">Header Text Color</span><div class="customize-control-notifications-container" style="display: none;"><ul></ul></div>
   
   
       		<div class="customize-control-content">
       			<div class="wp-picker-container"><button type="button" class="button wp-color-result" aria-expanded="false" style="background-color: rgb(255, 255, 255);"><span class="wp-color-result-text">Select Color</span></button><span class="wp-picker-input-wrap hidden"><label><span class="screen-reader-text">Header Text Color</span>
   
       				<input class="color-picker-hex wp-color-picker" type="text" maxlength="7" placeholder="#fff" data-default-color="#fff">
   
       			</label><input type="button" class="button button-small wp-picker-default" value="Default" aria-label="Select default color"></span><div class="wp-picker-holder"><div class="iris-picker iris-mozilla iris-border" style="width: 255px; height: 202.125px; padding-bottom: 23.2209px; display: none;"><div class="iris-picker-inner"><div class="iris-square" style="width: 182.125px; height: 182.125px;"><a class="iris-square-value ui-draggable ui-draggable-handle" href="#" style="left: 0px; top: 0px;"><span class="iris-square-handle ui-slider-handle"></span></a><div class="iris-square-inner iris-square-horiz" style="background-image: -moz-linear-gradient(left, rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255));"></div><div class="iris-square-inner iris-square-vert" style="background-image: -moz-linear-gradient(rgba(0, 0, 0, 0), rgb(0, 0, 0));"></div></div><div class="iris-slider iris-strip" style="height: 205.346px; width: 28.2px; background-image: -moz-linear-gradient(rgb(255, 0, 0), rgb(255, 255, 255));"><div class="iris-slider-offset ui-slider ui-corner-all ui-slider-vertical ui-widget ui-widget-content"><span tabindex="0" class="ui-slider-handle ui-corner-all ui-state-default" style="bottom: 0%;"></span></div></div></div><div class="iris-palette-container"><a class="iris-palette" tabindex="0" style="background-color: rgb(0, 0, 0); height: 19.5784px; width: 19.5784px; margin-left: 0px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(255, 255, 255); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(241, 196, 15); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(231, 76, 60); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(26, 188, 156); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(30, 114, 189); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(142, 68, 173); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(0, 204, 119); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a></div></div></div></div>
       		</div>
       				</li><li id="customize-control-amp_header_background_color" class="customize-control customize-control-color">
   
   
       			<span class="customize-control-title">Header Background & Link Color</span><div class="customize-control-notifications-container" style="display: none;"><ul></ul></div>
   
   
       		<div class="customize-control-content">
       			<div class="wp-picker-container"><button type="button" class="button wp-color-result" aria-expanded="false" style="background-color: rgb(241, 98, 2);"><span class="wp-color-result-text">Select Color</span></button><span class="wp-picker-input-wrap hidden"><label><span class="screen-reader-text">Header Background & Link Color</span>
   
       				<input class="color-picker-hex wp-color-picker" type="text" maxlength="7" placeholder="#0a89c0" data-default-color="#0a89c0">
   
       			</label><input type="button" class="button button-small wp-picker-default" value="Default" aria-label="Select default color"></span><div class="wp-picker-holder"><div class="iris-picker iris-mozilla iris-border" style="display: none; width: 255px; height: 202.125px; padding-bottom: 23.2209px;"><div class="iris-picker-inner"><div class="iris-square" style="width: 182.125px; height: 182.125px;"><a class="iris-square-value ui-draggable ui-draggable-handle" href="#" style="left: 12.1417px; top: 9.10625px;"><span class="iris-square-handle ui-slider-handle"></span></a><div class="iris-square-inner iris-square-horiz" style="background-image: -moz-linear-gradient(left, rgb(255, 0, 0), rgb(255, 128, 0), rgb(255, 255, 0), rgb(128, 255, 0), rgb(0, 255, 0), rgb(0, 255, 128), rgb(0, 255, 255), rgb(0, 128, 255), rgb(0, 0, 255), rgb(128, 0, 255), rgb(255, 0, 255), rgb(255, 0, 128), rgb(255, 0, 0));"></div><div class="iris-square-inner iris-square-vert" style="background-image: -moz-linear-gradient(rgba(0, 0, 0, 0), rgb(0, 0, 0));"></div></div><div class="iris-slider iris-strip" style="height: 205.346px; width: 28.2px; background-image: -moz-linear-gradient(rgb(240, 96, 0), rgb(242, 242, 242));"><div class="iris-slider-offset ui-slider ui-corner-all ui-slider-vertical ui-widget ui-widget-content"><span tabindex="0" class="ui-slider-handle ui-corner-all ui-state-default" style="bottom: 99%;"></span></div></div></div><div class="iris-palette-container"><a class="iris-palette" tabindex="0" style="background-color: rgb(0, 0, 0); height: 19.5784px; width: 19.5784px; margin-left: 0px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(255, 255, 255); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(241, 196, 15); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(231, 76, 60); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(26, 188, 156); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(30, 114, 189); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(142, 68, 173); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a><a class="iris-palette" tabindex="0" style="background-color: rgb(0, 204, 119); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a></div></div></div></div>
       		</div>
       				</li><li id="customize-control-amp_color_scheme" class="customize-control customize-control-radio">									<span class="customize-control-title">Color Scheme</span><div class="customize-control-notifications-container" style="display: none;"><ul></ul></div>
   
       									<span class="customize-inside-control-row">
       						<input id="_customize-input-amp_color_scheme-radio-light" type="radio" value="light" name="_customize-radio-amp_color_scheme" data-customize-setting-link="amp_customizer[color_scheme]" checked="checked">
       						<label for="_customize-input-amp_color_scheme-radio-light">Light</label>
       					</span>
       									<span class="customize-inside-control-row">
       						<input id="_customize-input-amp_color_scheme-radio-dark" type="radio" value="dark" name="_customize-radio-amp_color_scheme" data-customize-setting-link="amp_customizer[color_scheme]">
       						<label for="_customize-input-amp_color_scheme-radio-dark">Dark</label>
       					</span>
       								</li></ul>
       ```
   
 *  Thread Starter [Marty](https://wordpress.org/support/users/bozzmedia/)
 * (@bozzmedia)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16066472)
 * Color Codes:
    #ffffff #f16202
 * I sent in the form with other system info. Thanks!
    -  This reply was modified 3 years, 8 months ago by [Marty](https://wordpress.org/support/users/bozzmedia/).
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16066509)
 * What may be helpful is if you can edit the source code of this method:
 * [https://github.com/ampproject/amp-wp/blob/a373ac8f65f26ee7df7313ff5d734b5704781ab0/src/ReaderThemeSupportFeatures.php#L364-L382](https://github.com/ampproject/amp-wp/blob/a373ac8f65f26ee7df7313ff5d734b5704781ab0/src/ReaderThemeSupportFeatures.php#L364-L382)
 * Before these lines:
 *     ```
       // Get red, green, blue.
       $red   = hexdec( substr( $hex, 0, 2 ) );
       $green = hexdec( substr( $hex, 2, 2 ) );
       $blue  = hexdec( substr( $hex, 4, 2 ) );
       ```
   
 * Add this:
 * `error_log( '$hex === ' . json_encode( $hex ) );`
 * Then trigger whatever you do to cause the deprecation notice, and then open the
   error log to look for that log entry. You may need to [enable](https://wordpress.org/support/article/debugging-in-wordpress/#wp_debug_log)`
   WP_DEBUG_LOG`.
 *  Thread Starter [Marty](https://wordpress.org/support/users/bozzmedia/)
 * (@bozzmedia)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16066535)
 * Done. This popped up:
 * `Uncaught exception 'ParseError' with message 'syntax error, unexpected token"&"'
   in /home/redacted/public_html/wp-content/plugins/amp/src/ReaderThemeSupportFeatures.
   php:374`
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16066576)
 * Er, that’s not expected. Copy/paste error?
 *  Thread Starter [Marty](https://wordpress.org/support/users/bozzmedia/)
 * (@bozzmedia)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16066593)
 * Here’s what I have:
 *     ```
       		error_log( '$hex === ' . json_encode( $hex ) );
       		// Get red, green, blue.
       		$red   = hexdec( substr( $hex, 0, 2 ) );
       		$green = hexdec( substr( $hex, 2, 2 ) );
       		$blue  = hexdec( substr( $hex, 4, 2 ) );
       ```
   
 *  Thread Starter [Marty](https://wordpress.org/support/users/bozzmedia/)
 * (@bozzmedia)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/#post-16066595)
 * Here’s the line from debug:
 * `[04-Oct-2022 00:37:28 UTC] $hex === "var(--base-2)"`
 * Possibly set from the theme, GeneratePress?

Viewing 15 replies - 1 through 15 (of 20 total)

1 [2](https://wordpress.org/support/topic/php-8-0-compatibility-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/php-8-0-compatibility-error/page/2/?output_format=md)

The topic ‘PHP 8.0 compatibility error’ is closed to new replies.

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

 * 20 replies
 * 3 participants
 * Last reply from: [Marty](https://wordpress.org/support/users/bozzmedia/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-0-compatibility-error/page/2/#post-16069566)
 * Status: resolved