Title: PHP &#8211; Syntax
Last modified: February 22, 2023

---

# PHP – Syntax

 *  Resolved [K. M.](https://wordpress.org/support/users/blarney27/)
 * (@blarney27)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/php-syntax-3/)
 * I’m getting these error messages, do you know what the issue is and how to fix
   it?
 * 2023/02/22 03:27:28 [error] 123236#123236: *261645 FastCGI sent in stderr: “PHP
   message: PHP Warning: Undefined array key “name” in /www/XXXXXXXXX/public/wp-
   content/plugins/code-snippets/php/snippet-ops.php(505) : eval()’d code on line
   3″ while reading response header from upstream, client: 35.236.17.54, server:
   [http://www.XXXXXX.com](http://www.XXXXXX.com), request: “HEAD /XXXXXXXXXX/ HTTP/
   1.1”, upstream: “fastcgi://unix:/var/run/php8.0-fpm-XXXXXXX.sock:”, host: “XXXXXXXXX”,
   referrer: “[https://XXXXXXXXXXX&#8221](https://XXXXXXXXXXX&#8221);

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

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/php-syntax-3/#post-16504593)
 * Hi [@blarney27](https://wordpress.org/support/users/blarney27/),
 * This is an error coming from one of your snippets. You have an array and are 
   trying to access the `['name']` key, but that key does not exist.
 * Unfortunately, it’s not something I can fix in the plugin, but if you’re able
   to find the snippet causing the error and post the code here, I’m happy to help
   debug. Searching for `name @line:3` might help.
 *  Thread Starter [K. M.](https://wordpress.org/support/users/blarney27/)
 * (@blarney27)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/php-syntax-3/#post-16505126)
 * Thank you for the follow up, much appreciated. I only have one snippet; here 
   it is:
 * function remove_page_from_query_string($query_string)
   {if ($query_string[‘name’]
   == ‘page’ && isset($query_string[‘page’])) {unset($query_string[‘name’]);$query_string[‘
   paged’] = $query_string[‘page’];}return $query_string;}add_filter(‘request’, ‘
   remove_page_from_query_string’);
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/php-syntax-3/#post-16505465)
 * Hi Kevin,
 * Here’s how you could rewrite that snippet to prevent errors:
 *     ```wp-block-code
       add_filter( 'request', function ( $query_string ) {
       	if ( isset( $query_string['page'], $query_string['name'] ) && 'page' === $query_string['name'] ) {
       		unset( $query_string['name'] );
       		$query_string['paged'] = $query_string['page'];
       	}
       	return $query_string;
       } );
       ```
   
 *  Thread Starter [K. M.](https://wordpress.org/support/users/blarney27/)
 * (@blarney27)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/php-syntax-3/#post-16506995)
 * Great! Thank you for your help, it’s very much appreciated!
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/php-syntax-3/#post-16507063)
 * No worries! Glad to help.

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

The topic ‘PHP – Syntax’ is closed to new replies.

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

 * 5 replies
 * 2 participants
 * Last reply from: [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * Last activity: [3 years, 2 months ago](https://wordpress.org/support/topic/php-syntax-3/#post-16507063)
 * Status: resolved