Custom functionLOGIN

Custom function

Custom functions

PHP has more than 1,000 built-in functions, so functions make PHP a very powerful language. Most of the time we can meet our needs by using the system's built-in functions, but custom functions encapsulate a set of codes to reuse the code and make the program structure and logic clearer.

How to define PHP functions:
1. Start with the keyword "function"
2. The function name can start with a letter or an underscore: function name()
3. In braces Write the function body in:

function name() { echo 'Eric'; }

Through the above steps, we have defined a simple function when we need it , you can call this function in the code. The calling method is function name + parameters, for example: name();

Next Section
<?php function _pr(){ echo "这是个自定义函数"; } _pr(); ?>
submitReset Code
ChapterCourseware