constants 修改_PHP Constants Aptitude问题与解答

constants 修改

This section contains Aptitude Questions and Answers on PHP Constants.

本节包含有关PHP常数的 Aptitude问题和解答。

1) There are the following statements that are given below, which of them are correct about constants in PHP?
  1. Constants are just like variables, but its value cannot be changed.

  2. A valid constant name starts with an alphabet or underscore.

  3. There is no need to use the '$' symbol with constants.

  4. All the above

Options:

  1. A and B

  2. B and C

  3. A and C

  4. D

Answer & Explanation

Correct answer: 4
D

All given statements are correct about the constants in PHP.

1)下面给出了以下语句,其中哪些对于PHP中的常量是正确的?
  1. 常量就像变量一样,但是其值不能更改。

  2. 有效的常量名称以字母或下划线开头。

  3. 不需要在常量中使用'$'符号。

  4. 以上全部

选项:

  1. A和B

  2. B和C

  3. A和C

  4. d

答案与解释

正确答案:4
d

所有给定的语句对于PHP中的常量都是正确的。

2) Which of the following function is used to define a constant in PHP?
  1. defconst()

  2. define()

  3. const()

  4. def()

Answer & Explanation

Correct answer: 2
define()

The define() function is used to define a constant in PHP.

2)以下哪个函数用于在PHP中定义常量?
  1. defconst()

  2. define()

  3. const()

  4. def()

答案与解释

正确答案:2
define()

define()函数用于在PHP中定义一个常量。

3) Can we create a case-sensitive constant in PHP?
  1. Yes

  2. No

Answer & Explanation

Correct answer: 1
Yes

Yes, we can create a case-sensitive constant in PHP.

3)我们可以在PHP中创建区分大小写的常量吗?
  1. 没有

答案与解释

正确答案:1

是的,我们可以在PHP中创建一个区分大小写的常量。

4) What is the correct output of the given code snippets?
<?php
	define("COUNTRY", "INDIA");
	echo COUNTRY;
?>

  1. INDIA

  2. COUNTRY

  3. Garbage value

  4. Error

Answer & Explanation

Correct answer: 1
INDIA

The above code will print "INDIA" on the webpage.

4)给定代码段的正确输出是什么?
  1. 印度

  2. 国家

  3. 垃圾价值

  4. 错误

答案与解释

正确答案:1
印度

上面的代码将在网页上打印“ INDIA”

5) What is the correct output of the given code snippets?
<?php
	define("COUNTRY", "INDIA");
	echo country;
?>

  1. INDIA

  2. country

  3. Garbage value

  4. Error

Answer & Explanation

Correct answer: 2
country

The above code will print the "country" on the webpage.

5)给定代码段的正确输出是什么?
  1. 印度

  2. 国家

  3. 垃圾价值

  4. 错误

答案与解释

正确答案:2
国家

上面的代码将在网页上打印“国家”

6) What is the correct output of the given code snippets?
<?php
	define("COUNTRY", "INDIA",true);
	echo country;
?>

  1. INDIA

  2. country

  3. Garbage value

  4. Error

Answer & Explanation

Correct answer: 1
INDIA

The above code will print INDIA on the webpage.

6)给定代码段的正确输出是什么?
  1. 印度

  2. 国家

  3. 垃圾价值

  4. 错误

答案与解释

正确答案:1
印度

上面的代码将在页面上打印印度 。

7) What is the correct output of the given code snippets?
<?php
	define("COUNTRY", "INDIA",true);
	{
    		define("COUNTRY", "BHARAT",true);
	    	echo country;
    	}
?>

  1. INDIA

  2. country

  3. BHARAT

  4. Error

Answer & Explanation

Correct answer: 1
INDIA

The above code will print "INDIA" on the webpage.

7)给定代码段的正确输出是什么?
  1. 印度

  2. 国家

  3. 巴拉特

  4. 错误

答案与解释

正确答案:1
印度

上面的代码将在网页上打印“ INDIA”

8) What is the correct output of the given code snippets?
<?php
	define("COUNTRY", "INDIA",true);
	{
    		redefine("COUNTRY", "BHARAT",true);
    		echo country;
    	}
?>

  1. INDIA

  2. country

  3. BHARAT

  4. Error

Answer & Explanation

Correct answer: 4
Error

The above code will generate an error because redefine() is not an inbuilt function in PHP.

8)给定代码段的正确输出是什么?
  1. 印度

  2. 国家

  3. 巴拉特

  4. 错误

答案与解释

正确答案:4
错误

上面的代码将产生错误,因为redefine()不是PHP中的内置函数。

9) What is the correct output of the given code snippets?
<?php
	define("COUNTRIES", {"INDIA","AUSTRALIA","USA"});
	echo COUNTRIES[1];    
?>

  1. INDIA

  2. AUSTRALIA

  3. Error

  4. Garbage value

Answer & Explanation

Correct answer: 3
Error

The above code will generate an error because it is not the correct way to define a constant array.

9)给定代码段的正确输出是什么?
  1. 印度

  2. 澳大利亚

  3. 错误

  4. 垃圾价值

答案与解释

正确答案:3
错误

上面的代码将产生错误,因为这不是定义常量数组的正确方法。

10) What is the correct output of the given code snippets?
<?php
	define("COUNTRIES", ["INDIA","AUSTRALIA","USA"]);
	echo COUNTRY[1];    
?>

  1. INDIA

  2. AUSTRALIA

  3. 0

  4. Error

Answer & Explanation

Correct answer: 3
0

The above code will print "0" on the webpage because the COUNTRY constant is not defined.

10)给定代码段的正确输出是什么?
  1. 印度

  2. 澳大利亚

  3. 0

  4. 错误

答案与解释

正确答案:3
0

上面的代码将在网页上打印“ 0”,因为未定义COUNTRY常量。

11) What is the correct output of the given code snippets?
<?php
	define("COUNTRIES", ["INDIA","AUSTRALIA","USA"]);
	echo COUNTRIES[1];    
?>

  1. INDIA

  2. AUSTRALIA

  3. 0

  4. Error

Answer & Explanation

Correct answer: 2
AUSTRALIA

The above code will print "AUSTRALIA" on the webpage.

11)给定代码段的正确输出是什么?
  1. 印度

  2. 澳大利亚

  3. 0

  4. 错误

答案与解释

正确答案:2
澳大利亚

上面的代码将在网页上打印“ AUSTRALIA”

12) What is the correct output of the given code snippets?
<?php
	define("COUNTRY", "INDIA");
	
    	function fun()
    	{
    		echo COUNTRY;    
    	}
?>

  1. INDIA

  2. 0

  3. Error

  4. None of the above

Answer & Explanation

Correct answer: 4
None of the above

The above code will not print anything on the webpage because fun() is not called anywhere in the code.

12)给定代码段的正确输出是什么?
  1. 印度

  2. 0

  3. 错误

  4. 以上都不是

答案与解释

正确答案:4
以上都不是

上面的代码不会在网页上打印任何内容,因为在代码的任何地方都没有调用fun() 。

13) What is the correct output of the given code snippets?
<?php
    define("COUNTRY", "INDIA");
    
    function fun()
    {
        echo COUNTRY;    
    }
    
    fun();
?>

  1. INDIA

  2. 0

  3. Error

  4. None of the above

Answer & Explanation

Correct answer: 1
INDIA

The above code will print "INDIA" on the webpage.

13)给定代码段的正确输出是什么?
  1. 印度

  2. 0

  3. 错误

  4. 以上都不是

答案与解释

正确答案:1
印度

上面的代码将在网页上打印“ INDIA”

14) What is the correct output of the given code snippets?
<?php
	define("COUNTRY", "INDIA");
	
    	function fun()
    	{
    		define("COUNTRY", "USA");
	    	echo COUNTRY;    
    	}
    
	fun();
?>

  1. INDIA

  2. USA

  3. Error

  4. None of the above

Answer & Explanation

Correct answer: 1
INDIA

The above code will print "INDIA" on the webpage.

14)给定代码段的正确输出是什么?
  1. 印度

  2. 美国

  3. 错误

  4. 以上都不是

答案与解释

正确答案:1
印度

上面的代码将在网页上打印“ INDIA”

15) What is the correct output of the given code snippets?
<?php
	define("POLICE", 100);
	
    	function fun()
    	{
    		echo POLICE;    
    	}
    
    	fun();
?>

  1. 100

  2. POLICE

  3. Error

  4. None of the above

Answer & Explanation

Correct answer: 1
100

The above code will print "100" on the webpage.

15)给定代码段的正确输出是什么?
  1. 100

  2. 警察

  3. 错误

  4. 以上都不是

答案与解释

正确答案:1
100

上面的代码将在网页上打印“ 100”

翻译自: https://www.includehelp.com/php/constants-aptitude-questions-and-answers.aspx

constants 修改

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值