Jump to content

Strict Standards:


richanderson

Recommended Posts

Hi Guys,

 

So first time beginner coder and I have been doing a lot of tutorials. I tend to be the kinda person to Google stuff before I post and I really couldnt find help with my issue. So first, my code (Please disregard the comments in the code as its for my own use later so I know what I did)

 

 

session_start(); // Deals with login sections

$path = dirname(__FILE__); // Is the entire path up on this script

include("{$path}/register.inc.php");
include("{$path}/login.inc.php");

mysql_connect ("localhost","root","");
mysql_select_db ("coding");

//Scrint name is path from root directory. anything after .com of a site Explode function takes a character and it breaks up a string to decide where space is. - 4 means it takes off .php to give you init.inc for logging in
$page_name = substr(end(explode("/", $_SERVER['SCRIPT_NAME'])), 0, -4);

 

So when I run the above, on my page I get Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\coding\inc\init.inc.php on line 24

 

 

I am following this tutorialand it happens around 13:10 in the video.

 

Really appreciate any help here as its driving me up the walls.

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/274610-strict-standards/
Share on other sites

http://www.php.net/manual/en/function.end.php

 

See how end expects a variable passed by reference?

 

I personally haven't encountered this but I wonder if doing it this way will resolve the error:

$arr = explode("/", $_SERVER['SCRIPT_NAME']);
$page_name = substr(end($arr), 0, -4);

 

Edit: Actually I'm 99% sure that would fix it.

"The array. This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference." From the manual.

Link to comment
https://forums.phpfreaks.com/topic/274610-strict-standards/#findComment-1413045
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.