pro_php thread: SV: Easy question...
Already connected.
And use require instead, because it halts if the file doesn't exist
while include continues.
And use require_once if you don't want the same file to get included
more than once.
PHP parses included file as they were part of you first php file.
Example
<?php
//func.php
Function checkthisout()
{
echo "y0 y0 y0";
}
?>
<?php
//main.php
require_once("func.php");
Echo "hey hoe";
?>
In the phpcompiler it isnt two files, but one:
<?php
function checkthisout()
{
echo "y0 y0 y0";
}
echo "hey hoe";
?>
Ask if you don't understand
-----Ursprungligt meddelande-----
Fr=E5n: Bill [mailto:bige88fan@c...]
Skickat: den 5 november 2002 17:03
Till: professional php
=C4mne: [pro_php] Easy question...
Just wanted to know something. Let's say I have a file, which calls for
another function inside of another file which is included into the
origin
file. I have connected to the mysql database inside of the origin file,
is
it neccessary to connect inside of each indivual function if I am
already
connected in the origin file? Here is an example:
<?php
//origin.php
connect();
get_data("test_tlb","car");
?>
<?php
//functions.php
function get_data($table,$field){
connect();
$query =3D mysql_query("SELECT $field FROM $table");
$result =3D mysql_result($query,0,$field);
}
?>
Basically what connect does is connect to the database. I made a
function
for it. So is it really neccessary to call connect() inside of the
function get_data()? I'm thinking that if it's not, could it increase
the
speed of my script slightly? And also, any other tips on increasing the
speed of any script? Thanks guys!