communication
 databases
 directories
 file handling
 html and code
 image editing
 image listing
 sessions and co
 string handling
 information
 forms
 apple stuff
 image handling
 array handling
 lixlpixel
php - snippets
google search terms detected and highlighted.
remove highlighting | keep highlighting
make snippet in "html and code" - download "view php source" - open demo of "view php source"
 search
php - snippets

Valid CSS!

php webring logo
prev next
random list
join the Ring!

html and code - view php source was created/last modified on Mon 19 Apr 2004 8:34 AM

this will show you the source with syntax-highlighting
              
<?php
               
  
echo '<form name="form1" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
   
// echo '<input type="text" name="selected_file">'; // disabled for demo
  
echo '<input type="text" name="xxx" value="index.php">'; // bogus field
  
echo '<input type="hidden" name="selected_file" value="index.php">'; // just for demo
  
echo '<input type="submit" value="View">';
  echo
'</form>';
  echo
'<hr>';
     
  
// security - checks for the right referrer
  
if(substr($_SERVER['HTTP_REFERER'],-strlen($_SERVER["PHP_SELF"])) == $_SERVER["PHP_SELF"])
     
$real_adress = 1;
  else
     
$real_adress = 0;

  if(!
$_POST['selected_file'] == '' && $real_adress == 1)
  {
      
$userfile = $_POST['selected_file'];
      echo
'<b>full path:</b> ' . $userfile;
      
      
$myArray = split('/', $userfile);
      
$selected_file_name = end($myArray);
      echo
'<br /><b>filename:</b> ' . $selected_file_name . '<hr>';
      
$strFile = file($selected_file_name);
      
$newStr = join(" ",$strFile);
      
      echo
'<div style="background:whitesmoke;">';
  
       
#HTML comment "start copy here"
       
echo "\n\n\n<!--// -----\n";
       echo
"START COPY HERE\n";
       echo
"----- -->\n\n\n";
      
      
highlight_string($newStr);
      
      
// HTML comment "END copy here"
      
echo "\n\n\n<!--// -----\n";
      echo
"END COPY\n";
      echo
"----- -->\n\n\n";
  
      echo
'</div>';
                  
      echo
'<p><hr><i>End Of File</i></p>';
  }else{
      echo
'Please select a file.';
  }
               
?>

learn more about some of the PHP functions used in this snippet: copy, echo, else, end, file, for, highlight_string, join, round, split, strlen, substr

view the GNU general license - view the GNU library license - search on PHPsnippets - see your code like this

 a lixlpixel.com site

PHParadise.com - PHP-classes.org - your site on safari