Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
375 views
in Technique[技术] by (71.8m points)

php - 如何在PHP中轻松定义变量(How to Define a Variable in PHP easily [duplicate])

I want to know How to Define a Variable in PHP easily.

(我想知道如何轻松地在PHP中定义变量。)

Please share your experience.

(请分享您的经验。)

Actually I'm new in PHP.so I want to learn PHP variable in deeply.

(实际上我是PHP的新手,所以我想深入学习PHP变量。)

I find many tutorials but i'm so confused where actually I have to start.

(我找到了很多教程,但是我很困惑,实际上我必须从哪里开始。)

  ask by Linda translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I would recommend you to learn about Statements, types of statements, expressions also.

(我建议您学习语句,语句类型,表达式。)

Because, it will be sooner or later includes variables.

(因为,迟早会包含变量。)

Coming back to variable.

(回到变量。)

Just mention intent of variable in it's name prefixed by $.

(只需在变量名称中以$开头提及变量的意图即可。)

For example:

(例如:)

$name = "John Doe";

($ name =“ John Doe”;)

$age 34;

(年龄34岁;)

...many more for boolean, array, objects.

(...还有更多有关布尔,数组,对象的信息。)

Learn about associative arrays.

(了解关联数组。)

You don't need to mention type of variable.

(您无需提及变量的类型。)

The expression on right at runtime will decide type of data of a variable on left side.

(运行时右侧的表达式将决定左侧变量的数据类型。)

Learn about statements and expressions.

(了解有关语句和表达式的信息。)

And it will clear your concepts in any language.

(它将以任何语言清除您的概念。)

Like $result = $first + 3;

(像$ result = $ first + 3;)

Is whole statement which contains variable declaration and initialization.

(是包含变量声明和初始化的整个语句。)

Initialization expressions consists of variable $first, operator+ and literal 3 which is integers.

(初始化表达式由变量$ first,operator +和常量3组成。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...