Home  >  Article  >  Web Front-end  >  A brief analysis of the differences between js functions and php functions

A brief analysis of the differences between js functions and php functions

PHPz
PHPzforward
2016-05-16 16:20:531977browse

This article mainly introduces the difference between js functions and php functions. It briefly analyzes the differences in syntax and application between js functions and php functions in the form of examples. It has certain reference value. Friends who need it can refer to it.

This article analyzes the difference between js functions and php functions with examples. Share it with everyone for your reference. The specific analysis is as follows:

In PHP syntax, a function is a grammatical structure, not a variable and cannot be assigned a value;

In JS, a function is also a type of variable, and the variable name is function name.

<html>
<head>
</head>
<body>
<script type="text/javascript">
function t(){
 return 5;
}
var m = t;//函数名即是变量名。注意,不能写成t(),加括号是表示调用这个函数。
alert(m());
</script>
</body>
</html>

So, the function can also be declared like this:

t = function(参数){
 函数体;
}
Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete