简体   繁体   中英

How do I call a 'conscruct of functions' that are included in a PHP-file or a Javascript-file?

I can code a (tiny) little bit and now have to communicate with a real Web Developer. I don't want to look like a total newbie right off the bat, which is why I would like to address my question:

I generate form data via my website which is processed via a form action that is coded in php. The form action (action.php) in turn triggers other php files. The php files include functions, variables, basically all kinds of stuff is going on and the files are all linked together to process the form data (save it to mySQL database, send form data via e-mail, post data to CRM etc.).

My question is: How do I call this entire php-coded construct? Would it be called a php script? And how do I call the individual php-files? They are more than functions I guess, php-functions are only part of these files. Furthermore, if my form action was coded in Javascript, how would I call the entire thing and how would I call the individual Javascript files?

I hope my question makes sense. I am a bit shaky with the terminology, I hope you can help me.

Example of my php-code:

This 'form action' is triggered when people push the SEND button on my website (action.php):

<?php

    header("Location: https://etcetctect");

    include 'variables.php';

    include 'mysql.php';

    include 'phpword.php';

    include 'sendmail.php';

    include 'curltwo.php';

    include 'curlthree.php';

    include 'curlfour.php';

Then, for example, one of the executed files looks like this:

<?php

// Include Variables --> NEED
include 'variables.php';

$xml =  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
    <Leads>
        <row no=\"1\">
            <FL val=\"Uhrzeit\">".$uhrzeit."</FL>       
            <FL val=\"Datum\">".$datum."</FL>
            <FL val=\"First Name\">".$firstname."</FL>
            <FL val=\"Last Name\">".$lastname."</FL>
            <FL val=\"Phone\">".$phone."</FL>
            <FL val=\"Email\">".$email."</FL>
            <FL val=\"Zip Code\">".$postcode."</FL>
            <FL val=\"fuerwen\">".$fuerwen."</FL>
            <FL val=\"pflegegrad\">".$pflegegrad."</FL>
            <FL val=\"mobilitaet\">".$mobilitaet."</FL>
            <FL val=\"sprache\">".$sprache."</FL>
            <FL val=\"betreuungsbeginn\">".$zeitpunkt."        </FL>
        </row>
    </Leads>";
$auth="HDUIWHUIDHWQUIHDWUQIHDUQW";
    $url ="https://crm.zoho.com/crm/private/xml/Leads/insertRecords";
        $query="authtoken=".$auth."&scope=crmapi&newFormat=1&xmlData=".$xml;
    $ch = curl_init();
    /* set url to send post request */
    curl_setopt($ch, CURLOPT_URL, $url);
    /* allow redirects */
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    /* return a response into a variable */
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    /* times out after 30s */
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    /* set POST method */
    curl_setopt($ch, CURLOPT_POST, 1);
    /* add POST fields parameters */
    curl_setopt($ch, CURLOPT_POSTFIELDS, $query);// Set the request     as a POST FIELD for curl.

    //Execute cUrl session
    $response = curl_exec($ch);
    curl_close($ch);
    echo $response;

How would I call these files individually and how would I call the entire construct as a whole?

You may get a few different answers here so go with what makes the most sense to you.

How do I call this entire php-coded construct? Would it be called a php script?

No - each individual file is a script. I would call the entire thing, " the form processor " or " the form handler ".

Ex. The form processor is expecting a POST request, not a GET request

And how do I call the individual php-files? They are more than functions I guess, php-functions are only part of these files.

They are script files or scripts.

Ex. Please take a look at my variables script file on line ...

If you have classes/objects within those files then you could specically mention the class name.

Ex. The Authentication class is responsible for logging you in.

Furthermore, if my form action was coded in Javascript, how would I call the entire thing and how would I call the individual Javascript files?

I would call them the same as I would in PHP - " scripts " and " form processor ".

Some other important distinctions when talking about forms & processors are:

  • client-side vs. server-side ( We perform validation on the server-side )
  • " includes " are files that are referenced within your script with include , require etc. ( Can you please take a look at the variables include on line...? )

I'm not sure what actually you are asking. But if you ask about how to call included php file function. Then you need to know mechanism about include. let say you have 3 files

  • fileA.php function actionA () {}
  • fileB.php function actionB () {}
  • fileC.php function actionC () {}

then you include fileA.php, fileB.php, fileC.php into master.php.

Your master.php structure after you include it actually like this

master.php

  // include from fileA.php
  function actionA () {}
  // include from fileB.php
  function actionB () {}
  // include from fileC.php
  function actionC () {}

You can call the function like they are in same file as master.php

actionC();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM