What is the difference between echo,print () and Print_r ()?

Source: Internet
Author: User
Tags echo date
This article mainly introduces Echo,print () and Print_r () what is the difference between interested friends to understand.

What is the difference between 1.echo,print () and Print_r ()?
Echo is a language structure with no return value. Print is a function that returns a value of type int. Print_r () is a function that returns the value of the bool type value, which is the output variable by structure.
2. In HTTP 1.0, the meaning of status code 401 is (not authorized, the current request requires user authentication), if the "File not found" prompt, the header function is available, the statement is ("http/1.0 404 Not Found").
3. $str = "CD";
$ $str = "Hotdog"; <==> $cd = "Hotdog";
$ $str. = "OK";
echo $cd; <==> "Hotdogok".
4.echo 3. Print (2). Print (4). 5. ' C ';//45c2131 (please refer to the previous blog post for such questions)operational analysis of the Echo and print and '. ' operator blending in PHP"There is an introduction inside)
5.echo ' 2 '. Print (2) +3;//521
6.echo Print (8). ' A '; 8a
7.print (8). ' A '; 8a
8. The time format of the day before printing in PHP is 2006-5-10 22:21:21
echo Date ("Y-m-d h:i:s", Strtotime ("1 day"));
9.echo $var = $value;//$value
10.echo 0 = = "a";//1
One . ($tmp = 0) = = "a"? 1:2;
echo $tmp;//0
$tmp = (0 = = "a")? 2:3;
echo $tmp;//2
$tmp = 0 = = "a"? 2:3;
echo $tmp;//2
$b = ' 1d9 ';
echo + + $b;//1e0
$a = ' 1d9 '; $a = $a + 1; echo $a;//operation ' 1D9 ' only takes the number before the character = ' 1 ' and then participates in the operation: 1+1=2.
$array = new Arrayobject ();
if (empty ($array))
{echo ' 0 ';}
Else
{echo ' 1 ';}
Var_dump ($array);//object (Arrayobject) #1 (1) {["Storage": "Arrayobject":p rivate]=> Array (0) {}}
the answer is 1.
$a = "Hello"; $b = & $a; unset ($b); $b = "World"; the value of variable A is ("Hello")
$a = "Hello"; $b = & $a; unset ($b); @var_dump ($a, $b);//string (5) "Hello" NULL
b points to A's memory space, but a is not deleted when B is deleted.
17. A group of monkeys in a circle, according to 1,2,...,n sequentially numbered. Then, starting from the 1th, Count to M., Kick It Out of the loop, start counting from behind it, Count to M., and Kick It out ... and so on, until the last monkey is left, the monkey is called the King. Requires programming to simulate this process, enter M, N, and output the number of the last king. Tip: Joseph Ring question

function Yuesefu ($n, $m) {      $r =0;      for ($i =2; $i <= $n; $i + +)      {         $r = ($r + $m)% $i;      }      return $r +1;    }    Echo (Yuesefu (5,3));


18.echo count ("abc");//1-Calculates the number of cells in an array or the number of attributes in an object.
19. How do I implement string flipping?
echo Strrev ("string");//gnirts
20. What is the difference between the statement include and the require?
require (): If the file does not exist, a fatal error is reported. The script stops executing; include (): If the file does not exist, it will give a warning, but the script will continue to execute.
21.if ($a = && $b = $) {
var_dump ($a, $b);//True,
}
$arr = [' 1 ', ' 2 '];
foreach ($arr as $k = = $v) {
if ($k = = 0) {
$adm = ' 3333 ';
} elseif ($k = = 1) {
$adm [] = ' Baidu ';
}
}
report syntax errors. Fatal error: [] operator not supported for strings
23. For the following code, the correct statement is:

<?php   class test{public      function __get ($str) {        echo ' access__get:: ' $str.        '--'; return [' fd ' = ' hy '];      }  $b = new Test ();  Var_dump ($b->member); print out [' fd ' = ' hy '];  Var_dump (Empty ($b->member));//print out what????   = = "true

A .
$bA = true; $bB = false;
$b 1 = $bA and $bB; $b 2 = $bA && $bB;
Var_dump ($b 1);//true
Var_dump ($b 2);//false
Var_dump ($bA and $bB);//false
var_dump ($bA && $bB)//false
Var_dump ($b 1); = "because the" = "has a higher precedence than" and ", the assignment is performed first, and then the and operation, but the result is not saved.
25. The math argument in JS is correct: (a,c,d)
A.math.ceil (m) returns a value greater than or equal to M
B.math.round (m) returns a value greater than or equal to M, example Math.Round (-3.1) returns-3;
C.math.floor (m) returns a value less than or equal to M
D.math.floor (-2.9); return-3
What are the types of errors in 26.PHP?
There are roughly 3 types of errors encountered in PHP.
tip: It's all very normal information, not a big mistake, and some won't even show it to the user. For example, access to non-existent variables.
Warning: This is a bit of a serious error that will present the warning message to the user, but will not affect the output of the code, such as containing some files that do not exist.
Error: This is a real serious error, such as accessing a nonexistent PHP class.
27. Which of the following functions is wrong: C
a.getimagesize ()
B.imagesx ()
c.file_get_content ()
D.imagesy ()
28.<script src= ' 1.js ' >alert (' 1 ');</script> output What [assumes 1.js file exists] (b)
A. No output, but alert a bit
B. No output, no alert
If you write the alert statement in the 1.js file, you will be alert.
29. The function is the same as the method, but the argument is different (b)
A. Yes, the function is the same as the method, and the term is different.
B. Not the same, and not a concept
30.echo 0 = = "; This sentence will print out?" (a)
A.1 b.0
.

$str = >>>eod
I saw a dog yesterday.
EOD;
Echo $str;
The above outputs: (c)
A.I saw a dog yesterday
B. Output an empty string
C. Syntax error, no echo result
32. Which of the following functions can open a file for read and write operations? (c)
A.fget ()
B.file_open ()
C.fopen ()
D.open_file ()
33.php is a compiled language (x), PHP is an interpreted language (√)
34.var_dump (Strpos (' Mrwagon ', 626)); Int (1)
The second parameter of this strpos needle is not a string! It is a string that appears to be false at a glance. However, the number is converted to the corresponding ASCII character to be processed. ASCII code can be converted to a range of 0~255.626/256=2 ... 114,114 the corresponding character is r, so the result is 1.
$arr = Array (' A ', ' B ', ' C ');
foreach ($arr as $k = = $v) {
echo Key ($arr), "= =", current ($arr), ';//1=>b 1=>b 1=>b
}
36. Which function is used for natural sorting: Natsort ().
37._ () is the shorthand for which function: GetText ().
In 38.thinkphp3, the directory structure is as follows:
Application
-----User
-----User---Action----->useraction.php
-----User---Module---->usermodule.php
-----API
-----API---Action------>apiaction.php
-----API---Module----->apimodule.php
Under User action, how do I invoke the contents of Api/module?
Apimodule.php there is a method: Getusernamebyuid, I in useraction.php how to call apimodule.php Getusernamebyuid method???
D (' Api/api ')->getusernamebyuid ();
39.
$arr = [' Hello ', ' world '];
while ($word = each ($arr)) {
$x = $arr;
}
At this point the value of $x is (dead loop). (Can not understand!!!) )
40. Get the Http://hdwo.net/?a+b=1 variable a+b in the URL, the following correct method
$_get[' A_b ']
41. Get the Http://hdwo.net/?a.b=1 variable a.b in the URL, the following correct method
$_get[' A_b ']

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.