What are the differences between echo, print() and print_r()?
This article mainly introduces the differences between echo, print() and print_r(). Interested friends can learn about it.
1. What is the difference between 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 a bool type value and outputs the value of the variable according to the structure.
2. In HTTP 1.0, the meaning of status code 401 is (unauthorized, the current request requires user verification); if a "File not found" prompt is returned, the header function can be used, which The statement is (header("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 (For such questions, please refer to the previous blog post "About
Operation analysis of mixed echo, print and '.' operators in PHP " is introduced in ")
5.echo '2'.print(2) 3 ;//521
6.echo print(8) . 'a'; //8a
7.print(8) . 'a'; // 8a
8. Use PHP to print out the time of the previous day in the format of 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
11. ($tmp = 0) == "a" ? 1: 2;
echo $tmp; // 0
12. $tmp = (0 == "a") ? 2: 3;
echo $tmp; // 2
13. $tmp = 0 == "a" ? 2: 3;
echo $tmp; // 2
14. $b = '1d9' ;
echo $b; // 1e0
$a='1d9'; $a = $a 1; echo $a;//If the operation is '1d9 'Only take the number before the character =>'1' and then participate in the operation: 1 1=2.
15. $array = new ArrayObject();
if(empty($array))
{ echo '0'; }
else
{ echo '1'; }
var_dump($array); //object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(0) { } }
The answer is 1.
16.$a = "hello"; $b = &$a; unset($b); $b = "world"; Variable The value of a is ("hello")
$a = "hello"; $b = &$a; unset($b); @var_dump($a,$b);// string(5) "hello" NULL
b points to the memory space of a, but a will not be deleted when b is deleted.
17. A group of monkeys line up in a circle and number them sequentially according to 1, 2,...,n. Then start counting from the 1st one, count to the mth one, kick it out of the circle, start counting from behind it, count to the mth one, kick it out..., and continue in this way until the end. Until there is only one monkey left, that monkey is called the king. Programming is required to simulate this process, input m, n, and output the number of the last king. Hint: 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));
$bA = true; $bB = false; $str = >>>EOD Related recommendations: Detailed introduction and usage of phpecho function Related knowledge and application of PHP 5 echo and print statements php implements testing of var_dump and echo output multi-variables The above is the detailed content of What are the differences between echo, print() and print_r()?. For more information, please follow other related articles on the PHP Chinese website!
18.echo count("abc"); // 1 -- Count the number of cells in the array or the number of attributes in the object.
19. How to implement string flipping?
echo strrev("string");//gnirts
20. What is the difference between the statement include and require?
require (): If the file does not exist, a fatal error will be reported. The script will stop execution; include(): If the file does not exist, a warning will be given, but the script will continue to execute.
21 .if ($a = 100 && $b = 200) {
var_dump($a, $b); // true, 200
}
22. $arr = ['1', '2'];
foreach($arr as $k => $v){
if($k == 0){
$adm = '3333';
} elseif($k == 1){
$ adm [] = 'Baidu';
##}
#} ## error. Fatal error: [] operator not supported for strings
23. Regarding 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);打印出['fd'=>'hy'];
var_dump(empty($b->member));//打印出什么????
==》true
$b1 = $bA and $bB; $b2 = $bA && $bB;
var_dump($b1); //true
var_dump($b2); //false
var_dump($bA and $bB);//false
var_dump($bA && $bB); //false
var_dump($b1);=》Because "=" is "and" has high priority, so the assignment operation is performed first, and then the and operation is performed, but the result is not saved.
25. The correct statement about Math in js is: (a,c,d)
a.Math.ceil(m) returns a value greater than or equal to m The value
b.Math.round(m) returns a value greater than or equal to m, for 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); returns -3
26.Error in PHP What are the types?
There are roughly three types of errors encountered in PHP.
Tips: These are very normal messages, not major errors, and some will not even be displayed to users. For example, access a variable that does not exist.
Warning: This is a serious error. A warning message will be displayed to the user, but it will not affect the output of the code, such as including some non-existent files.
Error: This is a really serious error, like accessing a non-existent PHP class.
27. Which of the following functions are wrong: c
a.getimagesize()
b.imagesx()
c.file_get_content()
d.imagesy()
28.What is the output [assuming 1.js file exists] (b)
a. No output, but an alert will be issued
b. No output, no alert
If you write the alert statement in the 1.js file, it will alert.
29. Functions and methods are the same, but their names are different (b)
a. Yes, functions and methods are the same, but their names are different
b. Different, and not the same concept
30.echo 0 == '';Will this sentence be printed? (a)
a.1 b.0
31.
I saw a dog yesterday.
EOD;
echo $str;
The above will output: (c)
a.I saw a dog yesterday
b. Output empty string
c. Syntax error, there will be no echo result
32. Which of the following functions can open a file for reading and writing operations on the file? (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 needle of this strpos is not a string! If it is a string, it will look false at first glance. But numbers must be converted into corresponding ASCII code characters for processing. The convertible range of ASCII code is 0~255.626/256=2...114, the corresponding character of 114 is r, so the result is 1.
35.$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 abbreviation of which function: gettext().
38. In 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
How to call things in Api/Module under User's Action?
There is a method in ApiModule.php: getUserNameByUID. How do I call the getUserNameByUID method in ApiModule.php in UserAction.php? ? ?
D('Api/Api')->getUserNameByUID();
39.
$arr = ['hello', 'world'];
while ($word = each($ arr)){
$x = $arr;
}
The value of $x at this time is (infinite loop). (Can’t understand!!!)
40. Get the variable a b of http://hdwo.net/?a b=1 in the URL. The following is the correct method
$_GET['a_b']
41 .Get the variable a.b in the URL http://hdwo.net/?a.b=1, the following is the correct method
$_GET['a_b']

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Export password-protected PDF in Photoshop: Open the image file. Click "File"> "Export"> "Export as PDF". Set the "Security" option and enter the same password twice. Click "Export" to generate a PDF file.

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

H5. The main difference between mini programs and APP is: technical architecture: H5 is based on web technology, and mini programs and APP are independent applications. Experience and functions: H5 is light and easy to use, with limited functions; mini programs are lightweight and have good interactiveness; APPs are powerful and have smooth experience. Compatibility: H5 is cross-platform compatible, applets and APPs are restricted by the platform. Development cost: H5 has low development cost, medium mini programs, and highest APP. Applicable scenarios: H5 is suitable for information display, applets are suitable for lightweight applications, and APPs are suitable for complex functions.

The necessity of registering VueRouter in the index.js file under the router folder When developing Vue applications, you often encounter problems with routing configuration. Special...

Detailed explanation of XPath search method under DOM nodes In JavaScript, we often need to find specific nodes from the DOM tree based on XPath expressions. If you need to...

不同数据库系统添加列的语法为:MySQL:ALTER TABLE table_name ADD column_name data_type;PostgreSQL:ALTER TABLE table_name ADD COLUMN column_name data_type;Oracle:ALTER TABLE table_name ADD (column_name data_type);SQL Server:ALTER TABLE table_name ADD column_name data_

Laravel and ThinkPHP are both popular PHP frameworks and have their own advantages and disadvantages in development. This article will compare the two in depth, highlighting their architecture, features, and performance differences to help developers make informed choices based on their specific project needs.

The state of the CentOS firewall can be viewed through the sudo firewall-cmd --state command, returning to running or not running. For more detailed information, you can use sudo firewall-cmd --list-all to view, including configured areas, services, ports, etc. If firewall-cmd does not solve the problem, you can use sudo iptables -L -n to view iptables rules. Be sure to make a backup before modifying the firewall configuration to ensure server security.
