How to create function in PHP with example [ detailed explanation with demo]

preview_player
Показать описание
The real power of PHP comes from its functions; it has more than 1000 built-in functions.

Besides the built-in PHP functions, we can create our own functions.

A function is a block of statements that can be used repeatedly in a program.

A function will not execute immediately when a page loads.

A function will be executed by a call to the function.
Create a User Defined Function in PHP
A user defined function declaration starts with the word "function":

Syntax
function functionName() {
code to be executed;
}
Note: A function name can start with a letter or underscore (not a number).

Tip: Give the function a name that reflects what the function does!

Function names are NOT case-sensitive.

In the example below, we create a function named "writeMsg()". The opening curly brace ( { ) indicates the beginning of the function code and the closing curly brace ( } ) indicates the end of the function. The function outputs "Hello world!". To call the function, just write its name:

Example
?php
function writeMsg() {
echo "Hello world!";
}

writeMsg(); // call the function
?
PHP Function Arguments
Information can be passed to functions through arguments. An argument is just like a variable.

Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma.

#thecodingbus
#function
#php
#webdevelopment
#how
#howto
#unitedstates
#USA
#usa

-~-~~-~~~-~~-~-
Please watch: "How to buy a domain name from GoDaddy 2019"

How to make a calling app in android

How to create drawing android app in MIT app inventor 2

How to make android calculator app using mit app

How to upload android app in google play store

how to create camera app in mit app inventor 2

How to create first android app in mit app inventor
-~-~~-~~~-~~-~- How to create an app for free using your mobile phone 2019

How to delete history in google chrome 2019 android

how to create camera app in mit app inventor 2

how to redirect http to https in Wordpress website

How to install wordpress in xampp step by step

How to add youtube video to wordpress website

how to create child theme in WordPress 2019

sdfhfdghjhjlqwerqwes werte qwexvnkl #USA lsdkfjsdlkfjd dfkajsdlfj lkdjsflkdjfdls The Coding Bus #unitedstates
#usa #TheCodingBus
#TCB #unitedstates #us
Рекомендации по теме
join shbcf.ru