Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2011
    Thanked 0 Times in 0 Posts

    Smile php function call from external PHP

    I want to call function in PHP i use require_once for this ....
    now i want to call the function in a particular event how it is done ?

    For example I have an function

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

    in error-status.php file .. (external file)
    now i want to cal this file in 2.php in between here
    else if($apply=="Add")

    seterror("0:|: :|: Add NTP server");

    //$error_text="NTP server already added"."\n"."Exiting ...";

    header("Location: datetime.php");
    can u help me fast ... how it is call ... i use require function for include ....
    Last edited by harry343; 04-26-2011 at 01:38 PM. Reason: modify

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,668 Times in 2,637 Posts
    I'm not sure I understand the problem here.
    As soon as you've included a local script into a running script, it will import any of the symbols from the included script into the scope of the running script, including variables, class templates, objects, constants, namespaces and functions. All you need to do is include it in and call the function.

    Now, if its a remote script, the only way to handle this (in a way that appears to call a function instead of capturing a result) would be to use a SOAP or similar transfer protocol.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  3. Users who have thanked Fou-Lu for this post:

    harry343 (04-27-2011)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts