1 The syntax difference between JavaScript and PHP

WBOY
Release: 2016-08-08 09:19:34
Original
1011 people have browsed it

1. Basic types

php的基本类型分别:
1.基本数据类型:整型、小数(float/double)、字符串、布尔类型
2.复合类型:数组、对象
3.特殊类型:Null,资源类型

JavaScript的基本类型:Undefined,Null,Boolean,NumberString。

区别:php 有资源类型,小数分单双精度,而Js的数的类型只是Number,且有Undefined类型。

Copy after login

2. String concatenation

 php 的字符串连接符是 :   "  .  "
 Js 的字符串连接符是 : "  +  "
Copy after login

3. Array addition

php 数组相加用:  " + ",可以直接相加
Js 用函数拼接: concat
Copy after login

4. Case sensitivity

php : 只有变量名区分大小写
Js : 全部区分大小写
Copy after login

5. Declare variables

php : 变量声明用 :  " $变量名 "
Js : 变量声明 : " var 变量名 "
Copy after login

6. Characters String function

php 求字符串长度等函数用单独的: strlen()
Js : 是面向对象的语言,String对象内置了函数,字符串.length,直接求。
Copy after login

7. Function parameter problem

php : 参数多传了可以,但不可以少传
Js : 传几个都可以,有 arguments 对象接收参数
Copy after login

Copyright statement: This article is an original article by the blogger and may not be reproduced without the permission of the blogger.

The above introduces the grammatical differences between 1 JavaScript and PHP, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
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!