php数据类型
This section contains Aptitude Questions and Answers on PHP Data Types.
本节包含有关PHP数据类型的 Aptitude问题和解答。
In PHP, variables can store different type of data that is allowed according to PHP data-types.
In PHP, there is no need to use special keywords to specify the data type of variable.
In PHP, we use the 'int' keyword to declare an integer type variable.
We use predefined classes to specify data-types in PHP.
Options:
Correct answer: 3
A and B
Statements A and B are correct about data-types in PHP.
在PHP中,变量可以存储根据PHP数据类型允许的不同类型的数据。
在PHP中,无需使用特殊关键字来指定变量的数据类型。
在PHP中,我们使用'int'关键字声明一个整数类型变量。
我们使用预定义的类来指定PHP中的数据类型。
选项:
正确答案:3
A和B
语句A和B关于PHP中的数据类型是正确的。
String
Array
Object
Resource
Options:
Correct answer: 4
A, B, C, and D
All given data-types are supported by PHP.
串
数组
目的
资源资源
选项:
正确答案:4
A,B,C和D
PHP支持所有给定的数据类型。
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.
正确答案:2
-2,147,483,648至2,147,483,647
在PHP中,我们使用4字节整数,则其范围是-2,147,483,648至2,147,483,647。
Correct answer: 3
var_dump()
The var_dump() function returns data-type of a variable and its value.
正确答案:3
var_dump()
var_dump()函数返回变量的数据类型及其值。
<?php
$num = 256;
var_dump(num);
?>
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.
正确答案:3
string(3)“ num”
上面的代码将在网页上打印一个string(3)“ num” ,因为在var_dump()函数中我们没有在变量名中使用$符号。
<?php
$num = 256;
var_dump($num);
?>
Correct answer: 1
int(256)
The above code will print "int(256)" on the web page.
正确答案:1
整数(256)
上面的代码将在网页上打印“ int(256)” 。
<?php
$num = 256;
$num1 = var_dump($num);
echo "num1 is ".$num1;
?>
Correct answer: 2
int(256) num1 is
The above code will print "int(256) num1 is" on the webpage.
正确答案:2
int(256)num1是
上面的代码将在网页上打印“ int(256)num1 is” 。
<?php
$num = "Hello";
var_dump($num);
?>
Correct answer: 3
string(5) "hello"
The above code will print [string(5) "hello"] on the web page.
正确答案:3
string(5)“你好”
上面的代码将在网页上打印[string(5)“ hello”]。
<?php
$num = 256;
var_dump($num);
$num = "Hello";
var_dump($num);
?>
Correct answer: 2
int(256) string(5) "Hello"
The above code will print [int(256) string(5) "Hello"] on the web page.
正确答案:2
int(256)字符串(5)“你好”
上面的代码将在网页上打印[int(256)string(5)“ Hello”]。
<?php
$num = true;
var_dump($num);
?>
Correct answer: 1
bool(true)
The above code will print "bool(true)" on the web page.
正确答案:1
布尔值(true)
上面的代码将在网页上打印“ bool(true)”。
<?php
$usrArray = array("ABC","PQR","XYZ");
var_dump($usrArray);
?>
Correct answer: 2
array(3) { [0]=> string(3) "ABC" [1]=> string(3) "PQR" [2]=> string(3) "XYZ" }
正确答案:2
array(3){[0] =>字符串(3)“ ABC” [1] =>字符串(3)“ PQR” [2] =>字符串(3)“ XYZ”}
<?php
$usrArray = array("ABC",786,"XYZ");
var_dump($usrArray);
?>
array(3) { [0]=> string(3) "ABC" [1]=> string(3) 786 [2]=> string(3) "XYZ" }
array(3) { [0]=> string(3) "ABC" [1]=> int(786) [2]=> string(3) "XYZ" }
Correct answer: 2
array(3) { [0]=> string(3) "ABC" [1]=> int(786) [2]=> string(3) "XYZ" }
array(3){[0] =>字符串(3)“ ABC” [1] =>字符串(3)786 [2] =>字符串(3)“ XYZ”}
array(3){[0] =>字符串(3)“ ABC” [1] => int(786)[2] =>字符串(3)“ XYZ”}
正确答案:2
array(3){[0] =>字符串(3)“ ABC” [1] => int(786)[2] =>字符串(3)“ XYZ”}
Correct answer: 1
Yes
In PHP, NULL is also data-type which can have only one value null.
<?php
$x = null;
var_dump($x);
?>
Correct answer: 1
NULL
The above code will print NULL on the webpage.
Correct answer: 1
Yes
Yes, we can create a user-defined class in the PHP script.
The resource type is used to contain the reference to the function.
The resource type is used to store the reference of external resources.
The resource type is used for the database call.
None of the above
Options:
Correct answer: 3
A, B, and C
Statements A, B, and C are correct about resource type in PHP.
资源类型用于包含对该函数的引用。
资源类型用于存储外部资源的引用。
资源类型用于数据库调用。
以上都不是
选项:
正确答案:3
A,B和C
关于PHP中的资源类型,语句A,B和C是正确的。
<?php
class Sample
{
function Sample()
{
$Var1 = "India";
}
}
// create an object of Sample class
$obj = new Sample();
echo $obj->$Var1;
?>
Correct answer: 2
Error
The above code will generate an error because $Var1 is not a member of the Sample class.
<?php
class Sample
{
function Sample()
{
$this->$Var1 = "India";
}
}
// create an object of Sample class
$obj = new Sample();
echo $obj->$Var1;
?>
Correct answer: 1
India
The above code will generate print "India" on the web page.
<?php
class Sample
{
function Sample()
{
$this->$Var2 = "Australia";
$this->$Var1 = "India";
}
}
// create an object of Sample class
$obj = new Sample();
var_dump($obj);
?>
Correct answer: 1
object(Sample)#1 (1) { [""]=> string(5) "India" }
正确答案:1
object(Sample)#1(1){[“”] => string(5)“ India”}
翻译自: https://www.includehelp.com/php/data-types-aptitude-questions-and-answers.aspx
php数据类型