Are include statement Functions the fastest
Posted: Fri Aug 01, 2014 11:50 am
Hi,
I am creating a database driven website from a prototype I created in MS-Access 2007. I have been programming a long time in many languages over the years but I am new to Website design, HTML, MySql and PHP. I completed a script which is shown below and it works (it is a little test actually). If you study it you will see I used an include statement to bring in a function then I execute the function. My concern with the use of the include statement to get the function and execute it is the same concern that the person rises at the link below. That being "if it has to go to the disk to get a function rather than using a simple branch across memory and back then it must be pretty slow by comparison".
http://stackoverflow.com/questions/2483 ... rom-memory
So without (yet at least) figuring out how to get all PHP files to sit in memory (including all functions stored in php files which are going to be drawn in via the include statement) is this the fastest way to get at functions that will be called from different PHP script files. After reading the link above, I did do a google search " how to get php scripts to stay in memory (in cache)" and found an interesting article which I will eventually read
http://www.brandonturner.net/blog/2009/ ... ode_cache/
but that is a few steps ahead of my level at this point - LOL.
Thanks,
John
I am creating a database driven website from a prototype I created in MS-Access 2007. I have been programming a long time in many languages over the years but I am new to Website design, HTML, MySql and PHP. I completed a script which is shown below and it works (it is a little test actually). If you study it you will see I used an include statement to bring in a function then I execute the function. My concern with the use of the include statement to get the function and execute it is the same concern that the person rises at the link below. That being "if it has to go to the disk to get a function rather than using a simple branch across memory and back then it must be pretty slow by comparison".
http://stackoverflow.com/questions/2483 ... rom-memory
So without (yet at least) figuring out how to get all PHP files to sit in memory (including all functions stored in php files which are going to be drawn in via the include statement) is this the fastest way to get at functions that will be called from different PHP script files. After reading the link above, I did do a google search " how to get php scripts to stay in memory (in cache)" and found an interesting article which I will eventually read
http://www.brandonturner.net/blog/2009/ ... ode_cache/
but that is a few steps ahead of my level at this point - LOL.
Thanks,
John
Code: Select all
<html>
<body>
<?php
// Create connection
$con=mysqli_connect("LOCALHOST","root","MyPassword","MyDatabase");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
include 'PHP_MJN_Query1.php';
$MyString = PHP_MJN_Query1(3);
$result = mysqli_query($con,$MyString);
while($row = mysqli_fetch_array($result)) {
echo $row['fldCCF_Key']. " " . $row['fldCCF_CityName'];
echo "<br>";
}
?>
</body>
</html>
Code: Select all
<?PHP
function PHP_MJN_Query1($Key) {
$qstring = "SELECT * FROM tblCountryCitiesFile Where fldCCF_Key<>$Key";
return $qstring;
}
?>