Advertisement
fcamuso

Corso recupero PHP lezione 2

Apr 23rd, 2023
941
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.35 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <?php
  4.    $righe_config = [];
  5.  
  6.    //apertura; in c++ sarebbe ifstream il_file("config.ini")
  7.    $il_file = @fopen("config.ini", "r");
  8.  
  9.    if ($il_file)
  10.    {
  11.     //ciclo di lettura
  12.     while( $riga_letta = fgets($il_file))
  13.       $righe_config[] = $riga_letta;
  14.  
  15.     //chiusura del file
  16.     fclose($il_file);
  17.    }
  18.    else
  19.    {    
  20.      //die("Impossibile aprire il file di configurazione config.ini");
  21.      echo "Impossibile aprire il file di configurazione config.ini";
  22.      header("refresh:3; url=index.html");
  23.    }
  24.  
  25.  
  26.    for ($i=0; $i<count($righe_config); $i++)
  27.     echo $righe_config[$i] . "<br>";
  28.  
  29.    if ($righe_config[2]===",")
  30.      echo "<h1>UGUALE</h1>";
  31.    else
  32.     echo "<h1>DIVERSO</h1>";
  33.    
  34.    
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  //$righe_config = file("config.ini", FILE_IGNORE_NEW_LINES); //legge tutte le righe nell'array
  51.  
  52.  
  53.   // for ($i=0; $i<count($righe_config); $i++)
  54.   // {
  55.   //   $righe_config[$i] = rtrim($righe_config[$i]);    
  56.   //   echo "#{$righe_config[$i]}#<br>\n";
  57.   // }
  58. ?>
  59.  
  60. <html lang="<?php echo "{$righe_config[0]}"; ?>">
  61. <head>
  62.   <meta charset="UTF-8">
  63.   <meta http-equiv="X-UA-Compatible" content="IE=edge">
  64.   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  65.   <title>Document</title>
  66. </head>
  67. <body>
  68.   <?php
  69.      
  70.   ?>
  71. </body>
  72. </html>
  73.  
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement