Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GodziLaravel's avatar

Why the string `http:` and `https:` are not displayed ?

When any output contains the string http: or https: it's not displayed !

example :

Route::get('test', function () {
      //dd('http://test https://test');
      return 'http://test https://test';
});

the code above returns : //test //test instead of http://test https://test !

but with dd('http://test https://test'); it works !

Is it related to the APP_ENV ?

0 likes
28 replies
GodziLaravel's avatar

@automica

Yes same problem ,

Route::get('test', function () {
    return view('test', ['name' => 'https:// and http://']);
});

returns : // and //

automica's avatar

@godzilaravel not sure what else you have installed but I get the same results @kyawnaingthu

Route::get('test', function () {
    return 'http://test https://test';
});

Route::get('test2', function () {
    //dd('http://test https://test');
    return view('test', ['name' => 'http://test https://test']);
});

test.blade.php

{{ $name }}

<br>

{!! $name !!}

results:

http://test https://test 
http://test https://test

what version of Laravel have you got?

GodziLaravel's avatar

@automica

Now I upgraded just today Laravel to 6 but I had this probleme since the previous version 5.8 !

automica's avatar

@godzilaravel I don’t have anything running laravel 6 to test unfortunately.

You could try without html entities being applied by doing

{!! $name !!}
GodziLaravel's avatar

@automica

same result , http: and https: are not displaying !

I changed also the php version to 7.4 and always same problem

I also deleted the vendor and I did composer install

automica's avatar

Can you disable JavaScript on your browser temporarily to see if it’s anything front end, stripping the http: part?

If you switch to using my blade (without any bootstrap or css) what does that return?

GodziLaravel's avatar

@automica

even if I disabled JS I have the same problem ,

but when I dd('https:// and http://'); I can see http: and https:

So :

Route::get('404', function () {
   
   return 'https:// and http://'; ==> http: is hidden
    
   dd('https:// and http://');  ==> http: is NOT  hidden
  
  return view('errors.404', ['name' => 'https:// and http://']); http: is hidden (js and css disabled)
});

Sinnbeck's avatar

Did you test in another browser or in an incognito tab?

What dev server are you using? Can you try php artisan serve

Sinnbeck's avatar

And did you try running php artisan serve and opening the webpage from there? Just to rule out homestead

GodziLaravel's avatar

@sinnbeck

Same error with php artisan serve and laravel homestead and also in remote server !

Also with fresh installation of homestead when they pull this project

siangboon's avatar

can you screenshot what it display in browser and with the inspector inspecting the element...

siangboon's avatar

this is not screenshot. I had tried to copy and paste your code in web.php and created a view, the result is just showing the full "http://test https://test" as expected....

i want to see the exactly what your browser showing (whether we can find any other odd things) and the inspector's result...

Sinnbeck's avatar

Is the project available on github so others can try it? It seems that noone can recreate the error, so I think it is project specific.

My best bet, is that you have some custom code that strips out http and https

GodziLaravel's avatar

@sinnbeck

It's a company project and it's not available on GitHub.

I was thinking to your solution to strip http and https

 $data =  str_replace(['http:', 'https:'], ['[http]', '[https]'], $value);
        return json_decode($data);

But is it possible to make one function to make this strip for the whole project ?

Sinnbeck's avatar

So I imagine this happens for all your developers? Perhaps do a search in the app folder for http and see what you find. Perhaps there is a service provider that strips all http and http

1 like
Sinnbeck's avatar

Can you post your composer.json file? Perhaps a package is doing it.

GodziLaravel's avatar

@sinnbeck

Here the package.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.2.5",
        "doctrine/dbal": "^3.0",
        "fideloper/proxy": "^4.0",
        "guzzlehttp/guzzle": "^6.3",
        "intervention/image": "^2.5",
        "laravel/framework": "6.0.*",
        "laravel/socialite": "^4.1",
        "laravel/tinker": "^1.0",
        "laravelcollective/html": "^6.2",
        "league/oauth2-client": "^2.4",
        "maatwebsite/excel": "^3.1",
        "renatomarinho/laravel-page-speed": "^1.8",
        "revolution/laravel-google-sheets": "^5.4",
        "spatie/laravel-activitylog": "^3.6"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^7.5"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

Sinnbeck's avatar

Consider whitelisting the routes where you dont want it, as I suggested :)

1 like
siangboon's avatar

This is not an ordinary behavior for a Laravel system, perhaps some customization to prevent hyperlink had implemented in the system by your company...

i would advice that should discuss/consult with the project owner or senior teammate who in-charge on the project...

Please or to participate in this conversation.