php数据类型_PHP数据类型能力问题和解答

php数据类型

This section contains Aptitude Questions and Answers on PHP Data Types.

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

1) There are the following statements that are given below, which of them are correct about data types in PHP?
  1. In PHP, variables can store different type of data that is allowed according to PHP data-types.

  2. In PHP, there is no need to use special keywords to specify the data type of variable.

  3. In PHP, we use the 'int' keyword to declare an integer type variable.

  4. We use predefined classes to specify data-types in PHP.

Options:

  1. Only A

  2. Only B

  3. A and B

  4. C and D

Answer & Explanation

Correct answer: 3
A and B

Statements A and B are correct about data-types in PHP.

1)下面给出了以下语句,其中哪些对于PHP中的数据类型是正确的?
  1. 在PHP中,变量可以存储根据PHP数据类型允许的不同类型的数据。

  2. 在PHP中,无需使用特殊关键字来指定变量的数据类型。

  3. 在PHP中,我们使用'int'关键字声明一个整数类型变量。

  4. 我们使用预定义的类来指定PHP中的数据类型。

选项:

  1. 只有一个

  2. 只有B

  3. A和B

  4. C和D

答案与解释

正确答案:3
A和B

语句A和B关于PHP中的数据类型是正确的。

2) There are the following data types that are given below, which of them are supported by PHP?
  1. String

  2. Array

  3. Object

  4. Resource

Options:

  1. A and B

  2. C and D

  3. A, B, and C

  4. A, B, C, and D

Answer & Explanation

Correct answer: 4
A, B, C, and D

All given data-types are supported by PHP.

2)下面提供了以下数据类型,PHP支持哪些数据类型?
  1. 数组

  2. 目的

  3. 资源资源

选项:

  1. A和B

  2. C和D

  3. A,B和C

  4. A,B,C和D

答案与解释

正确答案:4
A,B,C和D

PHP支持所有给定的数据类型。

3) Which of the following is the correct range of integer variable in PHP?
  1. -32768 to 32767

  2. -2,147,483,648 to 2,147,483,647

  3. -128 to 127

  4. None of the above

Answer & Explanation

Correct answer: 2
-2,147,483,648 to 2,147,483,647

In PHP we used 4-bytes integer then its range is from -2,147,483,648 to 2,147,483,647.

3)以下哪个是PHP中整数变量的正确范围?
  1. -32768至32767

  2. -2,147,483,648至2,147,483,647

  3. -128至127

  4. 以上都不是

答案与解释

正确答案:2
-2,147,483,648至2,147,483,647

在PHP中,我们使用4字节整数,则其范围是-2,147,483,648至2,147,483,647。

4) Which of following function is used to return data type of a variable and its value?
  1. get_type()

  2. var_type()

  3. var_dump()

  4. getType()

Answer & Explanation

Correct answer: 3
var_dump()

The var_dump() function returns data-type of a variable and its value.

4)以下哪个函数用于返回变量的数据类型及其值?
  1. get_type()

  2. var_type()

  3. var_dump()

  4. getType()

答案与解释

正确答案:3
var_dump()

var_dump()函数返回变量的数据类型及其值。

5) What is correct output of given code snippets in PHP?
<?php  
	$num = 256;
	var_dump(num);
?>

  1. int(256)

  2. integer(256)

  3. string(3) "num"

  4. None of the above

Answer & Explanation

Correct answer: 3
string(3) "num"

The above code will print a string(3) "num" on the webpage because we did not use the $ symbol with variable name in var_dump() function.

5)PHP中给定代码段的正确输出是什么?
  1. 整数(256)

  2. 整数(256)

  3. string(3)“ num”

  4. 以上都不是

答案与解释

正确答案:3
string(3)“ num”

上面的代码将在网页上打印一个string(3)“ num” ,因为在var_dump()函数中我们没有在变量名中使用$符号。

6) What is correct output of given code snippets in PHP?
<?php  
	$num = 256;
	var_dump($num);
?>

  1. int(256)

  2. integer(256)

  3. string(3) "num"

  4. None of the above

Answer & Explanation

Correct answer: 1
int(256)

The above code will print "int(256)" on the web page.

6)PHP中给定代码段的正确输出是什么?
  1. 整数(256)

  2. 整数(256)

  3. string(3)“ num”

  4. 以上都不是

答案与解释

正确答案:1
整数(256)

上面的代码将在网页上打印“ int(256)”

7) What is correct output of given code snippets in PHP?
<?php  
	$num = 256;
	$num1 = var_dump($num);
	echo "num1 is ".$num1;
?>

  1. int(256) num1 is int(256)

  2. int(256) num1 is

  3. Syntax error

  4. None of the above

Answer & Explanation

Correct answer: 2
int(256) num1 is

The above code will print "int(256) num1 is" on the webpage.

7)PHP中给定代码段的正确输出是什么?
  1. int(256)num1是int(256)

  2. int(256)num1是

  3. 语法错误

  4. 以上都不是

答案与解释

正确答案:2
int(256)num1是

上面的代码将在网页上打印“ int(256)num1 is”

8) What is correct output of given code snippets in PHP?
<?php  
	$num = "Hello";
	var_dump($num);
?>

  1. string(hello)

  2. string("hello")

  3. string(5) "hello"

  4. None of the above

Answer & Explanation

Correct answer: 3
string(5) "hello"

The above code will print [string(5) "hello"] on the web page.

8)PHP中给定代码段的正确输出是什么?
  1. 字符串(你好)

  2. 字符串(“ hello”)

  3. string(5)“你好”

  4. 以上都不是

答案与解释

正确答案:3
string(5)“你好”

上面的代码将在网页上打印[string(5)“ hello”]。

9) What is correct output of given code snippets in PHP?
<?php  
	$num = 256;
	var_dump($num);

	$num = "Hello";
	var_dump($num);
?>

  1. int(256)

  2. int(256) string(5) "Hello"

  3. int(256) string(3)

  4. syntax error

Answer & Explanation

Correct answer: 2
int(256) string(5) "Hello"

The above code will print [int(256) string(5) "Hello"] on the web page.

9)PHP中给定代码段的正确输出是什么?
  1. 整数(256)

  2. int(256)字符串(5)“你好”

  3. int(256)字符串(3)

  4. 语法错误

答案与解释

正确答案:2
int(256)字符串(5)“你好”

上面的代码将在网页上打印[int(256)string(5)“ Hello”]。

10) What is correct output of given code snippets in PHP?
<?php  
	$num = true;
	var_dump($num);
?>

  1. bool(true)

  2. boolean(true)

  3. bool(4) "true"

  4. boolean(4) "true"

Answer & Explanation

Correct answer: 1
bool(true)

The above code will print "bool(true)" on the web page.

10)PHP中给定代码段的正确输出是什么?
  1. 布尔值(true)

  2. 布尔值(true)

  3. bool(4)“真”

  4. boolean(4)“ true”

答案与解释

正确答案:1
布尔值(true)

上面的代码将在网页上打印“ bool(true)”。

11) What is correct output of given code snippets in PHP?
<?php  
	$usrArray = array("ABC","PQR","XYZ");
	var_dump($usrArray);
?>  

  1. array(3) string

  2. array(3) { [0]=> string(3) "ABC" [1]=> string(3) "PQR" [2]=> string(3) "XYZ" }

  3. Syntax error

  4. None of the above

Answer & Explanation

Correct answer: 2
array(3) { [0]=> string(3) "ABC" [1]=> string(3) "PQR" [2]=> string(3) "XYZ" }

11)PHP中给定代码段的正确输出是什么?
  1. array(3)字符串

  2. array(3){[0] =>字符串(3)“ ABC” [1] =>字符串(3)“ PQR” [2] =>字符串(3)“ XYZ”}

  3. 语法错误

  4. 以上都不是

答案与解释

正确答案:2
array(3){[0] =>字符串(3)“ ABC” [1] =>字符串(3)“ PQR” [2] =>字符串(3)“ XYZ”}

12) What is correct output of given code snippets in PHP?
<?php  
	$usrArray = array("ABC",786,"XYZ");
	var_dump($usrArray);
?>  

  1. array(3) { [0]=> string(3) "ABC" [1]=> string(3) 786 [2]=> string(3) "XYZ" }

  2. array(3) { [0]=> string(3) "ABC" [1]=> int(786) [2]=> string(3) "XYZ" }

  3. Syntax error

  4. None of the above

Answer & Explanation

Correct answer: 2
array(3) { [0]=> string(3) "ABC" [1]=> int(786) [2]=> string(3) "XYZ" }

12)PHP中给定代码段的正确输出是什么?
  1. array(3){[0] =>字符串(3)“ ABC” [1] =>字符串(3)786 [2] =>字符串(3)“ XYZ”}

  2. array(3){[0] =>字符串(3)“ ABC” [1] => int(786)[2] =>字符串(3)“ XYZ”}

  3. 语法错误

  4. 以上都不是

答案与解释

正确答案:2
array(3){[0] =>字符串(3)“ ABC” [1] => int(786)[2] =>字符串(3)“ XYZ”}

13) In PHP, NULL is a data type?
  1. Yes

  2. No

Answer & Explanation

Correct answer: 1
Yes

In PHP, NULL is also data-type which can have only one value null.

13)在PHP中,NULL是数据类型吗?
  1. 没有

答案与解释

正确答案:1

在PHP中,NULL也是数据类型,只能有一个值null。

14) What is correct output of given code snippets in PHP?
<?php
	$x = null;
	var_dump($x);
?>

  1. NULL

  2. NULL(4)

  3. NULL(null)

  4. None of the above

Answer & Explanation

Correct answer: 1
NULL

The above code will print NULL on the webpage.

14)PHP中给定代码段的正确输出是什么?
  1. 空值

  2. 空(4)

  3. NULL(空)

  4. 以上都不是

答案与解释

正确答案:1
空值

上面的代码将在网页上显示NULL。

15) Can we create a user-defined class in the PHP script?
  1. Yes

  2. No

Answer & Explanation

Correct answer: 1
Yes

Yes, we can create a user-defined class in the PHP script.

15)我们可以在PHP脚本中创建用户定义的类吗?
  1. 没有

答案与解释

正确答案:1

是的,我们可以在PHP脚本中创建一个用户定义的类。

16) There are the following statements that are given below, which of them are correct about resource type in PHP?
  1. The resource type is used to contain the reference to the function.

  2. The resource type is used to store the reference of external resources.

  3. The resource type is used for the database call.

  4. None of the above

Options:

  1. A and B

  2. B and C

  3. A, B, and C

  4. D

Answer & Explanation

Correct answer: 3
A, B, and C

Statements A, B, and C are correct about resource type in PHP.

16)下面给出了以下语句,其中哪些对PHP中的资源类型是正确的?
  1. 资源类型用于包含对该函数的引用。

  2. 资源类型用于存储外部资源的引用。

  3. 资源类型用于数据库调用。

  4. 以上都不是

选项:

  1. A和B

  2. B和C

  3. A,B和C

  4. d

答案与解释

正确答案:3
A,B和C

关于PHP中的资源类型,语句A,B和C是正确的。

17) What is the correct output of given code snippets in PHP?
<?php

	class Sample 
    	{
  		function Sample() 
        		{
    			$Var1 = "India";
  		}
	}

	// create an object of Sample class
	$obj = new Sample();

	echo $obj->$Var1;
?>

  1. India

  2. Error

Answer & Explanation

Correct answer: 2
Error

The above code will generate an error because $Var1 is not a member of the Sample class.

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

  2. 错误

答案与解释

正确答案:2
错误

上面的代码将产生错误,因为$ Var1不是Sample类的成员。

18) What is the correct output of given code snippets in PHP?
<?php

	class Sample 
    {
  		function Sample() 
        {
    		$this->$Var1 = "India";
  		}
	}

	// create an object of Sample class
	$obj = new Sample();

	echo $obj->$Var1;
?>

  1. India

  2. Error

Answer & Explanation

Correct answer: 1
India

The above code will generate print "India" on the web page.

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

  2. 错误

答案与解释

正确答案:1
印度

上面的代码将在网页上生成打印“印度”。

19) What is the correct output of given code snippets in PHP?
<?php

	class Sample 
    {
  		function Sample() 
        {
            $this->$Var2 = "Australia";
            $this->$Var1 = "India";
  		}
	}

	// create an object of Sample class
	$obj = new Sample();

	var_dump($obj);
?>

  1. object(Sample)#1 (1) { [""]=> string(5) "India" }

  2. object(Sample)#1 (2) { [""]=> string(5) "Australia" }

  3. Error

  4. None of the above

Answer & Explanation

Correct answer: 1
object(Sample)#1 (1) { [""]=> string(5) "India" }

19)PHP中给定代码段的正确输出是什么?
  1. object(Sample)#1(1){[“”] => string(5)“ India”}

  2. object(Sample)#1(2){[“”] => string(5)“ Australia”}

  3. 错误

  4. 以上都不是

答案与解释

正确答案:1
object(Sample)#1(1){[“”] => string(5)“ India”}

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

php数据类型

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值