Title: PHP standards: calling reset() on a function return value throws warnings
Last modified: August 30, 2016

---

# PHP standards: calling reset() on a function return value throws warnings

 *  Resolved [Luis Rodrigues](https://wordpress.org/support/users/goblindegook/)
 * (@goblindegook)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/php-standards-calling-reset-on-a-function-return-value-throws-warnings/)
 * Hi,
 * We’ve been getting this warning in our environments:
 * `PHP Strict standards: Only variables should be passed by reference in /srv/www/
   site/wp-content/plugins/autoptimize/classes/autoptimizeStyles.php on line 262`
 * The warning is caused by the following code:
 * `if (strpos($iurl,'?') !== false) { $iurl = reset(explode('?',$iurl)); }`
 * The problem here is that `reset()` takes its parameter by reference, and so requires
   a variable while you’re passing it a function return value directly.
 * I would advise against using the code above, though, because the output of `reset(
   explode() )` is non-obvious. Most people I know use `reset()` to move back the
   array pointer and are not even aware that it also returns the first element.
 * `parse_url()` is the most suitable approach for this, but list destructuring (`
   list( $iurl ) = explode( '?', $iurl );`) or tokenization (`$iurl = strtok( $iurl,'?');`)
   would work too.
 * Hope this helps.
 * Best,
    Luís
 * [https://wordpress.org/plugins/autoptimize/](https://wordpress.org/plugins/autoptimize/)

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

 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/php-standards-calling-reset-on-a-function-return-value-throws-warnings/#post-6509735)
 * thanks for that, I’ll look into this shortly. don’t hesitate to issue a pull 
   request [on github](https://github.com/futtta/autoptimize) if you have a working
   alternative or if you’d like to collaborate on other improvements! 🙂
 * frank
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/php-standards-calling-reset-on-a-function-return-value-throws-warnings/#post-6509777)
 * ok, went for the tokenization approach, cfr. [https://github.com/futtta/autoptimize/commit/b83bdbc4b43aaf23220080fb2548f22ab18c50da](https://github.com/futtta/autoptimize/commit/b83bdbc4b43aaf23220080fb2548f22ab18c50da)
 * this will be in the next AO version, but you can off course [already download & install the latest dev-version from GitHub](https://github.com/futtta/autoptimize/archive/master.zip)
   or [browse the list of improvements & bugfixes](https://github.com/futtta/autoptimize/commits/master)
   here.
 * thanks for your tip!
    frank
 *  Thread Starter [Luis Rodrigues](https://wordpress.org/support/users/goblindegook/)
 * (@goblindegook)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/php-standards-calling-reset-on-a-function-return-value-throws-warnings/#post-6509826)
 * Github didn’t cross my mind, but I’ll start tracking your project there. Thanks!

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

The topic ‘PHP standards: calling reset() on a function return value throws warnings’
is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

## Tags

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

 * 3 replies
 * 2 participants
 * Last reply from: [Luis Rodrigues](https://wordpress.org/support/users/goblindegook/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/php-standards-calling-reset-on-a-function-return-value-throws-warnings/#post-6509826)
 * Status: resolved