Notice: Array to string conversion PHP

Next_Line_Nick

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.

luis_pmb

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to solve PHP error 'Notice: Array to string conversion in...'

From Dev

PHP Notice: Array to string conversion Error

From Dev

Array to string conversion notice when using implode

From Dev

notice: array to string conversion in php

From Dev

PHP Notice: Array to string conversion on line 10

From Dev

Need help fixing my error on Notice: Array to string conversion in

From Dev

Notice Array to string conversion using nusoap

From Dev

PHP: curl_setopt_array gives notice "array to string conversion"

From Dev

choice field symfony "Notice: Array to string conversion "

From Dev

Notice: Array to string conversion when using Foreach

From Dev

Notice Message: Array to string conversion

From Dev

PHP Notice: Array to string conversion only on PHP 7

From Dev

PHP Notice: Array to string conversion while using CURL to post data on remote server

From Dev

PHP Notice : Array to string conversion in and Unsupported operand types in

From Dev

PHP Notice: Array to string conversion on line 10

From Dev

Need help fixing my error on Notice: Array to string conversion in

From Dev

Notice: Array to string conversion with update statment

From Dev

choice field symfony "Notice: Array to string conversion "

From Dev

PHP: Array to string conversion

From Dev

Multidimensional array from query into string gives Array to string conversion notice

From Dev

Notice: Array to string conversion $text = $htmlTag[0]

From Dev

FOSRest Produces a Notice: Array to string conversion

From Dev

Keep getting Array to string conversion notice, but code works fine

From Dev

Codeigniter: Severity notice Message Array to String conversion

From Dev

Notice: Array to string conversion. without array in code

From Dev

PHP Notice: Array to string conversion when echoing json_decode()'ed data

From Dev

symfony Notice: Array to string conversion choicetype multi dimensional

From Dev

JSON TO CSV Conversion Notice: Array to string conversion in

From Dev

Notice: Array to String conversion - But it's a string in an array

Related Related

  1. 1

    How to solve PHP error 'Notice: Array to string conversion in...'

  2. 2

    PHP Notice: Array to string conversion Error

  3. 3

    Array to string conversion notice when using implode

  4. 4

    notice: array to string conversion in php

  5. 5

    PHP Notice: Array to string conversion on line 10

  6. 6

    Need help fixing my error on Notice: Array to string conversion in

  7. 7

    Notice Array to string conversion using nusoap

  8. 8

    PHP: curl_setopt_array gives notice "array to string conversion"

  9. 9

    choice field symfony "Notice: Array to string conversion "

  10. 10

    Notice: Array to string conversion when using Foreach

  11. 11

    Notice Message: Array to string conversion

  12. 12

    PHP Notice: Array to string conversion only on PHP 7

  13. 13

    PHP Notice: Array to string conversion while using CURL to post data on remote server

  14. 14

    PHP Notice : Array to string conversion in and Unsupported operand types in

  15. 15

    PHP Notice: Array to string conversion on line 10

  16. 16

    Need help fixing my error on Notice: Array to string conversion in

  17. 17

    Notice: Array to string conversion with update statment

  18. 18

    choice field symfony "Notice: Array to string conversion "

  19. 19

    PHP: Array to string conversion

  20. 20

    Multidimensional array from query into string gives Array to string conversion notice

  21. 21

    Notice: Array to string conversion $text = $htmlTag[0]

  22. 22

    FOSRest Produces a Notice: Array to string conversion

  23. 23

    Keep getting Array to string conversion notice, but code works fine

  24. 24

    Codeigniter: Severity notice Message Array to String conversion

  25. 25

    Notice: Array to string conversion. without array in code

  26. 26

    PHP Notice: Array to string conversion when echoing json_decode()'ed data

  27. 27

    symfony Notice: Array to string conversion choicetype multi dimensional

  28. 28

    JSON TO CSV Conversion Notice: Array to string conversion in

  29. 29

    Notice: Array to String conversion - But it's a string in an array

HotTag

Archive