Jump to content

Two problems, functions and variables!


onthespot

Recommended Posts

Hey guys,

My first problem is that i'm having trouble with a variable name.

 

$comp_name = "$subformat_$subgame_$subname_$subseason";
        $_SESSION['comp_name'] = $comp_name;

 

This seems to be returning just the value of $subseason?

Is there a quick fix for this?

 

Secondly, I am getting a undeclared function error.

 

I have two functions in my class. One of the functions calls the other function.

 

First function....

	function flip($match) 
{
	$components = split('v', $match);
	return $components[1] . "v" . $components[0];
}

 

Second function but only part of it (it's long!)....

 

$s = flip($r);

 

That is just a snippet of code from the second function.

I am not sure if i should be declaring the function a different way?

 

Thanks for reading  :D

Link to comment
https://forums.phpfreaks.com/topic/200400-two-problems-functions-and-variables/
Share on other sites

1. Variable Names

Variable names can contain underscores ( _ ), therefor you're asking it to echo $subformat_ rather than $subformat.

You need to use concatenation:

$comp_name = $subformat."_".$subgame."_".$subname."_".$subseason;

 

2. Deprecated Functions

Some old functions have been deprecated due to bugs and/or newer functions. Using functions such as split(); is not recommended:

http://uk3.php.net/split

 

3. Undeclared Function

The function name it states in the error could not be found in memory - This means you have either;

a) Typed the function name incorrectly (Function names are case-sensitive).

b) Called a function before the function has been declared (usually the cause of a bad if condition. Somtimes eval() and other similar functions).

c) Used an outdated PHP Function that no longer exists as part of PHP. Though usually PHP will give a DEPRECATED_FUNCTION Notice instead of an error.

 

-cb-

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.