how to include a php function in a class? -
how to include a php function in a class? -
i have class:
class connect { public function auth() { ... } }
and have function: getfile.php
<?php require_once($globals['path']."connect.php"); ?>
the have the: connect.php
<?php function connect( $host, $database ) { database connection here } ?>
how can utilize functions within class this:
class connect { require_once("getfile.php"); public function auth() { connect( $host, $database ) ... query } }
is possible?
thanks
functions declared in global scope available globally. don't have include need it, include file function in origin of script.
secondly,
class connect { require_once("getfile.php"); public function auth() { connect( $host, $database ) ... query } }
this jibberish; can't execute within class outside of methods. if want included when specific file needed in specific method, this:
class connect { public function auth() { require_once("getfile.php"); connect( $host, $database ) ... query } }
php class function require-once
Comments
Post a Comment