Home > Web Front-end > JS Tutorial > body text

js函数与php函数的区别实例浅析

PHPz
Release: 2018-09-29 17:33:03
forward
1934 people have browsed it

这篇文章主要介绍了js函数与php函数的区别,以实例形式较为简单的分析了js函数与php函数语法及应用上的不同点,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例分析了js函数与php函数的区别。分享给大家供大家参考。具体分析如下:

在PHP语法中,函数就是语法上的结构体,不是一个变量,不能被赋值;

在JS中,函数也是一种变量,变量名就是函数名。

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

所以,声明函数也可以这样:

t = function(参数){
 函数体;
}
Copy after login
Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!