Harsh Harsh - 1 year ago 63
PHP Question

How would I call a function in another file?

For example, I have a file error-status.php, which includes a function:

function validateHostName($hostName)
if ((strpbrk($hostName,'`~!@#$^&*()=+.[ ]{}\\|;:\'",<>/?')==FALSE) && !ctype_digit($hostName) && eregi("^([a-z0-9-]+)$",$hostName) && ereg("^[^-]",$hostName) && ereg("[^-]$",$hostName))
return true;
return false;


How do I call that function from a different PHP file after invoking


Answer Source

Include the file before you call the function.

include 'error-status.php';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download