简体   繁体   中英

Failed to load resource: the server responded with a status of 403 (Forbidden)

I am getting this error while deploy php project in wamp server.Actually i used codeigniter php framework.

request URL is http://localhost:80/index.php

below is the code.

<?
if(isset($js)){
  if(is_array($js)){
    if(count($js) >= 1){
        foreach($js as $file){
            if(file_exists("../www/js/{$file}")){
    ?>      
    <script type="text/javascript" language="javascript" src="<?php echo  
    base_url();?>js/<?=$file?>"></script>
    <?
            }
        }
    }
  } else {
    ?>      
    <script type="text/javascript" language="javascript" src="<?php echo 
    base_url();?>js/<?=$js?>"></script>
    <?
  }
}
?>

This is showing error on browser like

GET http://localhost/js/%3C?=$file?%3E 
GET http://localhost/js/%3C?=$js?%3E 

Why is this error occurring.Please help me.

This is probably because you are using PHP short_open_tags

ie

<?=$file?>

But in its default out of the box state PHP has the parameter turned off.

Edit php.ini to make sure you edit the correct php.ini file there are normally 2

Use the wampmanager menus -

wampmanager -> PHP -> php.ini

Search for

short_open_tags = Off

and change it to

short_open_tag = On

However the better solution would be to not use short tags, therefore your code will be universally transportable. So you could instead change the code to be

<?php echo $file;?>

It's a bit longer, but will work on any PHP configuration.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM