I am loading a friends site to play with it and it gives me this: Notice: Array to string conversion error. Any idea's how to fix this? (my friend is out of town)
function href($filename) {
if (@$_SERVER['HTTPS'] != 'on') {
return HTTP_IMAGE . $filename;
} else {
return HTTPS_IMAGE . $filename;
}
}
the error points to the 3rd line on this code.
You are using a string concatenation operator with something that is not a string. Namely, with an array.
Try this:
function href($filename) {
var_dump($HTTP_IMAGE);
var_dump($filename);
if (@$_SERVER['HTTPS'] != 'on') {
return HTTP_IMAGE . $filename;
} else {
return HTTPS_IMAGE . $filename;
}
}
When you run this code it should display whatever is inside HTTPS_IMAGE and $filename.
As I do not know what they contain, I will explain with the following sample code:
$my_array[0] = 'Hello';
$my_array[1] = 'world';
$my_array[2] = '!';
var_dump( $my_array );
If you execute that code you will obtain the following:
array(3) {
[0]=>
string(5) "Hello"
[1]=>
string(5) "world"
[2]=>
string(1) "!"
}
That is an array. It is a collection of elements, which need to be accessed by index. For instance, to access "world" you need to access it by its index, "1":
echo $my_array[1];
Returning to your example, identify which variable is an array and access it by the appropriate index. You will know which index is by inspecting the result of var_dump().
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments