4th parameter is for output ... long story short:

    $ php -a
    Interactive shell

    php > $foo = NULL;
    php > str_replace('http', 'https', 'http http', $foo);
    php > var_dump($foo);
    int(2)
    php > str_replace('http', 'https', 'http http', 1);
    PHP Fatal error:  Only variables can be passed by reference in php shell code on line 1