calling php function with a url
Posted: Thu Sep 16, 2010 1:35 pm
i have a previously created website that is getting incredibly big. I would like to reduce the number of pages by using php code which echos an html document.
My goal is to have an html link which calls this php function. Since i am just learning php i have been unsuccessful coming up with a way to do this. I have no experience with mysql so i am hoping to avoid setting up a database. as of now the only way i know to call the function is like this :
<?php moviePage('revolver.xml'); ?>
Any insight would be great. Thanks if you would like to see the partially finished page to get a better understanding the url is http://jasbo.isa-geek.com
<?php
function moviePage($file){
//loads & opens file
$filename = "lock.html";
$fp = fopen( $filename, "r" ) or die("Couldn't open $filename");
//shuffles through file line by line
while ( ! feof( $fp ) ) {$i++;
$line = fgets( $fp, 1024 );
$myText = (string)$line;
//if file contains certain text replaces it and replaces new text
if (strpos($myText, "Lock. Stock and Two Smoking Barrels[1998]DvDrip[Eng]-BugZ.xml") !== false) {echo str_ireplace("Lock. Stock and Two Smoking Barrels[1998]DvDrip[Eng]-BugZ.xml",$file,"$myText");}
//if not display original line
else echo $line;
}//end while
}//end function
?>
My goal is to have an html link which calls this php function. Since i am just learning php i have been unsuccessful coming up with a way to do this. I have no experience with mysql so i am hoping to avoid setting up a database. as of now the only way i know to call the function is like this :
<?php moviePage('revolver.xml'); ?>
Any insight would be great. Thanks if you would like to see the partially finished page to get a better understanding the url is http://jasbo.isa-geek.com
<?php
function moviePage($file){
//loads & opens file
$filename = "lock.html";
$fp = fopen( $filename, "r" ) or die("Couldn't open $filename");
//shuffles through file line by line
while ( ! feof( $fp ) ) {$i++;
$line = fgets( $fp, 1024 );
$myText = (string)$line;
//if file contains certain text replaces it and replaces new text
if (strpos($myText, "Lock. Stock and Two Smoking Barrels[1998]DvDrip[Eng]-BugZ.xml") !== false) {echo str_ireplace("Lock. Stock and Two Smoking Barrels[1998]DvDrip[Eng]-BugZ.xml",$file,"$myText");}
//if not display original line
else echo $line;
}//end while
}//end function
?>