简体   繁体   中英

PHP code works locally but not remotely

I cannot get this to produce what I want server side,which supports PHP, because I can get PHP pages to echo and stuff. but locally it does exactly what I expect it to do. this is of course example code I found lying around on the internet that I modified to look for my specific directory, that is the only thing i changed. Thanks in advanced for any help :) EDIT: apologies i forgot to clarify my goal. It is suppose to check a directory for .html files and construct a table with each file in the table. It does this locally but on the remote server im trying to host the code on, just produces a blank page.

<?php
  $directory = "/pages/";
  $contents = scandir($directory);
    if ($contents) {
       foreach($contents as $key => $value) {
             if ($value == "." || $value == "..") {
                unset($key);
             }
       }
    }
        echo "<ul>";
    foreach($contents as $k => $v) {
      echo "<li><a href=\"$directory/" . $v . "\">link text</a></li>";
    }
        echo "</ul>";

?>

User l'L'l pointed me in the right direction. error_reporting(E_ALL); helped me figure out what was wrong. the directory was a bit more complicated because i am using a subdomain for testing. and thought all i needed was "/pages/" as the directory.

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