0

I am trying to work on a forgot password system. I have no clue why I am getting this error, I've rechecked the code almost five times. Any help would be wonderful.

by the way, this is Exception.

Error- Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\core\init.php on line 8

recover.php

echo $current_file = end(explode('/', $_SERVER['SCRIPT_NAME']));
Gumbo
  • 643,351
  • 109
  • 780
  • 844
user1577002
  • 1
  • 1
  • 1
  • 1
    It's telling you the problem. It sounds like your passing something other than a variable by reference. Then, it tells you `line 8` of `recover.php`. – ChiefTwoPencils Aug 05 '12 at 06:21
  • possible duplicate of [Strict Standards: Only variables should be passed by reference](http://stackoverflow.com/questions/2354609/strict-standards-only-variables-should-be-passed-by-reference) – Lorenz Meyer Jun 21 '14 at 08:24

2 Answers2

3

This error seems to be because you are passing in a value to explode() rather than a variable, try this:

$var = $_SERVER['SCRIPT_NAME'];
$current_file = end(explode('/', $var));
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
Martin-Brennan
  • 917
  • 7
  • 19
2

As explained very well here, the PHP end() method waits for a variable reference to work correctly. What you have to do is simply give a variable reference instead of a plain value.

$var = $_SERVER['SCRIPT_NAME'];
$exploded = explode('/', $var);
$current_file = end($exploded);
Community
  • 1
  • 1
Jérôme
  • 616
  • 5
  • 15