Title: PHP errors when using search
Last modified: March 2, 2020

---

# PHP errors when using search

 *  Resolved [abbottwp](https://wordpress.org/support/users/abbottwp/)
 * (@abbottwp)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/php-errors-when-using-search/)
 * I have been getting an error whenever a search is done on my WordPress/Divi website.
   The results are listed, but there is an error listed first:
 * WARNING: USE OF UNDEFINED CONSTANT _THEMENAME_ – ASSUMED ‘_THEMENAME_‘ (THIS 
   WILL THROW AN ERROR IN A FUTURE VERSION OF PHP) IN /_path-to-the-theme_/SEARCH.
   PHP ON LINE 17
 * Line 16-18 of the search.php file are as follows:
 *  <header class=”page-header”>
    <span class=”search-page-title”> <?php printf(
   esc_html__( ‘Search Results for: %s’, _themename_ ), ‘<span>’ . get_search_query().‘
   </span>’ ); ?></span> </header><!– .page-header –>
 * WordPress ver: 5.3.2
    PHP ver: 7.3 Divi ver: 4.3.4 with a child theme
 * How do I fix this?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-errors-when-using-search%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  [Howdy_McGee](https://wordpress.org/support/users/howdy_mcgee/)
 * (@howdy_mcgee)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/php-errors-when-using-search/#post-12500569)
 * Hello,
 * You have in your code:
 * `esc_html__( 'Search Results for: %s', themename )`
 * The `themename` portion either should be a string literal `'themename'` or more
   likely replaced with the folder name of your theme (themeslug). For example, 
   when you installed the Twenty Twenty theme it’s theme folder is `twentytwenty`
   and it’s textdomain is `'twentytwenty'`. A similar example in Twenty Twenty would
   look like this:
 * `esc_html__( 'Search Results for: %s', 'twentytwenty' )`
 * The textdomain helps translations of your theme. You can see it as the 2nd parameter
   in any __*() functions -> [esc_html__()](https://developer.wordpress.org/reference/functions/esc_html__/).
   If this is a custom theme or you do not expect translations you could ignore 
   this parameter entirely:
 * `esc_html__( 'Search Results for: %s' )`
 * Currently, since it’s not encapsulated by quotes PHP thinks it’s a pre-defined
   constant that it should be looking for but cannot find ( since themename is not
   a defined constant ).
 *  Thread Starter [abbottwp](https://wordpress.org/support/users/abbottwp/)
 * (@abbottwp)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/php-errors-when-using-search/#post-12500606)
 * Yup, adding the quotes around the theme name worked. THANK YOU!!!!

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

The topic ‘PHP errors when using search’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [abbottwp](https://wordpress.org/support/users/abbottwp/)
 * Last activity: [6 years, 3 months ago](https://wordpress.org/support/topic/php-errors-when-using-search/#post-12500606)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
