PHP Incorrect Function

PHP Incorrect Function thumbnail
Secure servers purposefully withhold error details.

In the world of PHP server side scripting, an "incorrect function" could refer to anything from a syntactical error that is preventing the script from executing properly, to a function's name violating a project's conventions. If the error messages or feedback you are getting on your PHP code is too broad, you can look to a few common sources of PHP function issues.

  1. Message Text

    • If a syntactical issue exists with the functions in your PHP code, you will not see it until you go to actually execute the script. This is because, unlike with languages such as C++ or Java, PHP code is not compiled before execution. The PHP interpreter does not load a page's source code until a web browser actually requests a page containing PHP code. The detail in which the browser reports errors with PHP functions depends on the server's security settings. Security-conscious administrators will restrict detailed error messages to avoid hackers learning too much about the system by forcing a variety of errors.

    Function Call

    • One possible source of an incorrect error function is a call to an undefined function. While the PHP interpreter itself contains the code for all the functions in the standard library, programmers have to define their custom functions in order to execute them within the PHP script. Developers can put this definition in the script's source code file itself, or use the "include" command to have the interpreter reference another file for function declarations. Errors of this kind can be the result of forgetting to include the function declaration, or of making a typographical error in the function's name.

    Function Arguments

    • Data that a function accepts for processing by its own code are called arguments. When a function accepts arguments, the exact type and amount of data it can accept is part of the function's declaration. If the programmer tries to pass the wrong type of data into a function, or attempts to pass in data in the wrong sequence, the PHP interpreter will throw a function error. You can consult your own function declarations for the kinds of data a function will accept, and consult the PHP Manual to find this information for standard library functions.

    Naming Conventions

    • Programmers who are working on a project will come up with conventions to follow when naming functions. These will govern details such as if words should be separated by capital letters instead of spaces, for example as "threeLetterWord," or by underscores, as "three_letter_word." These conventions do not affect the PHP interpreter's ability to execute the code, but allow other programmers to call the project's specialized functions without double-checking their exact names. In this case, an incorrect function is one that is syntactically sound, but violates the naming conventions of a particular project.

Related Searches:

References

Resources

  • Photo Credit Hemera Technologies/AbleStock.com/Getty Images

Comments

Related Ads

Featured