Title: PHP Warning: ltrim() Problem in WordPress (formatting.php)
Last modified: February 18, 2021

---

# PHP Warning: ltrim() Problem in WordPress (formatting.php)

 *  [organikbesin](https://wordpress.org/support/users/organikbesin/)
 * (@organikbesin)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-warning-ltrim-problem-in-wordpress-formatting-php/)
 * Hi,
 * **I am writing this in shell;**
 * sudo tail -100 /var/log/apache2/error.log
 * **And, I saw this;**
 * ……
 * [Sun Feb 14 09:42:06.873076 2021] [php7:warn] [pid 1968] [client 82.222.237.83:
   36955] PHP Warning: ltrim() expects parameter 1 to be string, object given in/
   var/www/html/wp-includes/formatting.php on line 4314
 * [Sun Feb 14 09:42:06.873149 2021] [php7:warn] [pid 1968] [client 82.222.237.83:
   36955] PHP Warning: ltrim() expects parameter 1 to be string, object given in/
   var/www/html/wp-includes/formatting.php on line 4314
 * …
 * **I’m going to the relevant code.** –> /var/www/html/wp-includes/formatting.php
   on line 4314;
 *     ```
       function esc_url( $url, $protocols = null, $_context = 'display' ) {
           $original_url = $url;
   
           if ( '' === $url ) {
               return $url;
           }
   
           $url = str_replace( ' ', '%20', ltrim( $url ) );
           $url = preg_replace( '|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url );
   
           if ( '' === $url ) {
               return $url;
           }
   
           if ( 0 !== stripos( $url, 'mailto:' ) ) {
               $strip = array( '%0d', '%0a', '%0D', '%0A' );
               $url   = _deep_replace( $strip, $url );
           }
   
           $url = str_replace( ';//', '://', $url );
       ```
   
 * **on line 4314;**
 * `$url = str_replace( ' ', '%20', ltrim( $url ) );`
 * I did not understand. My error page is full of this. I could not figure out despite
   my research. Can you help me?
 * **Note**: Ubuntu 20.04, WordPress, Digitalocean
 * Healthy days, Best regards.

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

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-warning-ltrim-problem-in-wordpress-formatting-php/#post-14054275)
 * The warning is where the error was detected, not where it was caused.
 * This may be a plugin or theme conflict. Please attempt to disable all plugins,
   and use one of the default (Twenty*) themes. If the problem goes away, enable
   them one by one to identify the source of your troubles.
 *  [korvak](https://wordpress.org/support/users/korvak/)
 * (@korvak)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-warning-ltrim-problem-in-wordpress-formatting-php/#post-14063632)
 * Anyone know which plugin is causing this issue? I have the same issue and couldn’t
   figure it out yet.
 *  Thread Starter [organikbesin](https://wordpress.org/support/users/organikbesin/)
 * (@organikbesin)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-warning-ltrim-problem-in-wordpress-formatting-php/#post-14071103)
 * Finally found it! I couldn’t find the solution, but found out which plugin was
   causing this.
 * WooCommerce.
 * I’ve tested it many of times.It does not give an error when doing passive. It
   gives an error when it is activated.
 * How can I solve this?
 * Thanks.
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-warning-ltrim-problem-in-wordpress-formatting-php/#post-14071114)
 * I recommend asking at [https://wordpress.org/support/plugin/woocommerce/#new-post](https://wordpress.org/support/plugin/woocommerce/#new-post)
   so the plugin’s developers and support community can help you with this.
 *  [korvak](https://wordpress.org/support/users/korvak/)
 * (@korvak)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-warning-ltrim-problem-in-wordpress-formatting-php/#post-14071116)
 * [@organikbesin](https://wordpress.org/support/users/organikbesin/) — Do you mean
   WooCommerce itself causes that issue? If this is a bug with WooCommerce, I guess
   it needs to be reported to the WooCommerce team.
 *  Thread Starter [organikbesin](https://wordpress.org/support/users/organikbesin/)
 * (@organikbesin)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-warning-ltrim-problem-in-wordpress-formatting-php/#post-14071138)
 * I opened new support ticket in WooCommerce support.
 * [https://wordpress.org/support/topic/php-warning-ltrim-problem-in-wordpress-formatting-php-related-to-woocommerc/](https://wordpress.org/support/topic/php-warning-ltrim-problem-in-wordpress-formatting-php-related-to-woocommerc/)
    -  This reply was modified 5 years, 5 months ago by [organikbesin](https://wordpress.org/support/users/organikbesin/).

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

The topic ‘PHP Warning: ltrim() Problem in WordPress (formatting.php)’ is closed
to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [organikbesin](https://wordpress.org/support/users/organikbesin/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/php-warning-ltrim-problem-in-wordpress-formatting-php/#post-14071138)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
