I have honed my website to work fine on my localhost, but I am having trouble on my live server. When I declare variables in my views, and try to use them, I am getting js or php errors (depending on where I declare and use the variable). Here are the examples:
In js, I declare a php variable like so:
//in javascript
<? $id = Session::get('redirected_id'); ?>
@if(isset($id))
$('#myModal').modal('show');
@endif
Basically if I send a variable with the redirect to the view, I want this modal to appear. When I run this on localhost, all of the js works fine. When I run this on my live server, I get the error:
Uncaught SyntaxError: Unexpected token <
in reference to <? $id = Session::get('redirected_id'); ?>
<? $id = Session::get('redirected_id'); ?>
On another note, I am getting php errors on my live server when I declare a variable in the html portion, and then use it as an "offset" variable. For example:
<? $offset=0; ?>
@foreach($artists_near as $artist)
@if($offset%4==0 && $offset > 0)
<article class="MusicianCol clearfix fadeMusicBox" style="display:none;">
@endif
It is complaining at the line:
@if($offset%4==0 && $offset > 0)
saying:
Undefined variable: offset
This is strange because I am seeing no errors on the localhost. I am using the same declarations for jquery, etc.. on the pages using the blade syntax, so I should be including the same files. Any ideas?
Your production environment has the short_open_tag
setting disabled. For full compatibility its recommended that you do not turn it on and instance use the full php tag <?php
instead of <?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.