Fatal error: Call to undefined function function () in C: \ wamp \ www \ laravel-master \ app \ views \ hello.php

I wanted to learn laravel framework. I will be able to install laravel on my web server (Wamp) and I get a tutorial to learn it, but when I tried to style the h1 tag in the hello.php file along the way :( "C: \ wamp \ www \ laravel -master \ app \ views \ hello.php ") by the asset () function, the above error occurred. please help me figure out what the problem is. here hello.php codes:

        <style>

        body {
            margin:0;
            font-family:'Lato', sans-serif;
            text-align:center;
            color: #999;
        }

        .welcome {
            width: 300px;
            height: 200px;
            position: absolute;
            left: 50%;
            top: 50%;
            margin-left: -150px;
            margin-top: -100px;
        }

        a, a:visited {
            text-decoration:none;
        }

        h1 {
            font-size: 32px;
            margin: 16px 0 0 0;
        }
    </style>
</head>
   <link rel="stylesheet" type="text/css" href="<?php  echo asset('css/main.css'); ?>" >
<body>
    <div class="welcome">
        <a href="http://laravel.com" title="Laravel PHP Framework"> <img src="some_long_src" alt="Laravel PHP Framework"></a>
        <h1 class="highlight">You have arrived.</h1>
    </div>
</body>
</html>

      

and main.css:

.highlight {
    border: solid 2px #F00; 
}

      

and my laravel version is 4.2.16.

early.

+3


source to share


5 answers


Change this part:

<?php  echo asset('css/main.css'); ?>

      



like this:

/css/main.css

      

+1


source


You can try to do it like {{ HTML::style('css/main.css') }}



+1


source


Please note that you can use pure HTML:

<link rel="stylesheet" type="text/css" href="/css/main.css" >

      

+1


source


I am using Laravel version 5.2

and I have no problem with this:

  <!-- JavaScripts -->
    <script src="{{ asset('js/main.js') }}"></script>

      

+1


source


I faced the same strange situation today. Blade file with standard bootstrap links and jquery working fine when fullcalendar is added triggers this error. Removing fullcalendar works fine again, adding fullcalendar again error. It doesn't make sense to me because there is no 404 error, just"Call to undefined function asset()"

I tried replacing asset()

with url()

and everything works as expected.

0


source







All Articles