PDA

View Full Version : PHP Includes



Aflux
30-04-2007, 04:49 PM
Is it possible to include just 1 line of a PHP file?

Blob
30-04-2007, 05:04 PM
Why dont you just select that 1 line of the php code and replace the include with it

Aflux
30-04-2007, 05:08 PM
Because this would be easier for what I want doing.

Lilian
30-04-2007, 05:08 PM
You could put the line into a new file and then use this code to show that line:


<? include("Link to page here") ?>

Aflux
30-04-2007, 05:10 PM
I know I could do that, but I want to link it a specific line in a file - if it's possible.

Mentor
30-04-2007, 05:21 PM
Well a way you can kinda do this (on a generated page is)

$line = file("somedir/somefile.htm");
echo $line['15'];

From memoery, i think its the file command at least, i may have it confused im to lazy to check :P

Basicaly it puts the file contents in to an array split by the lines. so just echo out the array segment of the line you want, in this case line 16 (note array starts at zero so take account of that)

Splinter
30-04-2007, 05:45 PM
just use


<?php
$file = file("file.php");
eval($file[1]);
?>

Want to hide these adverts? Register an account for free!