About 346,000 results
Open links in new tab
  1. PHP Functions - W3Schools

    PHP has over 1000 built-in functions that can be called directly, from within a script, to perform a specific task. Please check out our PHP reference for a complete overview of the PHP built-in functions. Besides the built-in PHP functions, it is possible to create your own functions.

  2. PHP: Type declarations - Manual

    Type declarations can be added to function arguments, return values, as of PHP 7.4.0, class properties, and as of PHP 8.3.0, class constants. They ensure that the value is of the specified type at call time, otherwise a TypeError is thrown.

  3. PHP: Function parameters and arguments - Manual

    PHP supports passing arguments by value (the default), passing by reference, and default argument values. Variable-length argument lists and Named Arguments are also supported. As of PHP 7.3.0, it is possible to have a trailing comma in the argument list for a function calls:

  4. PHP | Functions - GeeksforGeeks

    Apr 12, 2025 · A function is declared by using the function keyword, followed by the name of the function, parentheses (possibly containing parameters), and a block of code enclosed in curly braces. Syntax function functionName($param1, $param2) { // Code to …

  5. How to Define and Call a Function in PHP - Tutorial Republic

    In this tutorial you will learn how to define and call a custom function in PHP to save the repetition of code and make your code much easier to maintain.

  6. PHP: User-defined functions - Manual

    User-defined functions. A function is defined using the function keyword, a name, a list of parameters (which might be empty) seperated by commas (,) enclosed in parentheses, followed by the body of the function enclosed in curly braces, such as the following:

  7. php: Declare arguments type of a Function - Stack Overflow

    Return type is declared using a colon, followed by return type. For example : function foo () : int { return 0; } According to PHP Manual, you can do that for array on PHP 5.1 and beyond and for string and int types on PHP 7 and beyond. Take a look: Class/interface name The parameter must be an instanceof the given class or interface name.

  8. Proper way to declare a function in PHP? - Stack Overflow

    Nov 23, 2009 · it's good practice to declare functions before calling them. It'll prevent infrequent misbehavior from your code. The sample is basically a valid function definition (meaning it runs, except for what Asaph mentions about closing braces), but doesn't follow best practices.

  9. PHP type declarations — A guide for beginners - Amit Merchant

    Dec 4, 2022 · Type declarations are a way to tell the PHP interpreter that a function argument should be of a certain type and that the function should return a value of a certain type. For example, if you want to declare a function that accepts only an integer as an argument, you can do so by specifying the type of the argument as int as follows.

  10. user-defined functions in PHP - w3resource

    Aug 19, 2022 · function function-name() { statement 1 : statement 2 : statement 3 : ..... } Elements of a function. function: A function declaration starts with the special word 'function'. Name of the function: The function name is defined by the user.

Refresh