1 The syntax difference between JavaScript and PHP

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

1. Basic types

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

JavaScript的基本类型:<span>Undefined</span>,<span>Null</span>,Boolean,<span>Number</span> 和 <span>String</span>。

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

</code>
Copy after login

2. String concatenation

<code> php 的字符串连接符是 :   <span>"  .  "</span>
 Js 的字符串连接符是 : <span>"  +  "</span></code>
Copy after login

3. Array addition

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

4. Case sensitivity

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

5. Declare variables

<code>php : 变量声明用 :  <span>" $变量名 "</span>
Js : 变量声明 : <span>" var 变量名 "</span></code>
Copy after login

6. Characters String function

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

7. Function parameter problem

<code>php : 参数多传了可以,但不可以少传
Js : 传几个都可以,有 <span>arguments</span> 对象接收参数</code>
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!