PHP Face questions and Answers

Source: Internet
Author: User
Tags echo date php print

1, in PHP print out the day before, the format is 2006-5-10 22:21:21

<? PHP
//echo date (' y-m-d h:i:s ', Time () -60*60*24
echo date("y:m:d h:i:s",strtotime("1 day"));
?>

2, Echo (), print (), Print_r () difference

Echo is a language structure with no return value;

The print function is basically the same as Echo, unlike the print function, which has a return value;

Print_r is a recursive print that is used to output array objects

3, the ability to make HTML and PHP separated from the use of the template

So much, in fact, PHP itself is a template engine, I used the smarty, common and phplib,fasttemplate,savant here is a list of templates engine:http://www.sitepoint.com/ forums/showthread.php?t=123769

4. How to implement PHP and JSP interaction?

The topic is a little vague, soap,xml_rpc,socket function,curl can achieve these, if it is a test of PHP and Java integration, PHP built-in this mechanism (if you test PHP and. NET integration, can also answer this), such as $foo = new Java (' Java.lang.System ');
5. which tools are used for version control?
CVS and SVN,SVN, known as the next generation of CVS, are powerful, but CVS is a veteran and has a high market share. I have been using SVN, the topic is to ask what tool, er, this may need to answer: CVS Server on Apache as the service side, Wincvs as a client; Subversion on Apache/dav do the server, TortoiseSVN do the client, or Subclipse do the client

6. How do I implement string flipping?

In fact, PHP itself has a function of string flipping: Strrev (), may wish to try Echo strrev ($STR), but all of these three methods do not solve the problem of Chinese string flipping, error.

Code<?Php
functionReverse ($Var)
{
$res="";
For($i=0, $j=Strlen ($Var< $j; $i ++)
     {
          $res =$[$i]. $res;
     }
    return  $res;
}
$tmpvar =;
$res =reverse ($tmpvar);
echo  $res;
?>


7, optimize the MySQL database method.

(1). Database design Aspects, this is the responsibility of the DBA and architect, the design of a well-structured database, when necessary, to regularization (English is this: denormalize, Chinese translation into what I do not know), allow partial data redundancy, avoid join operation, to improve query efficiency
(2). System architecture design, the table hash, the huge amount of data scattered into a few different tables. Slow table, fast table only stay up-to-date data, slower table is a historical archive. Cluster, master server Read & write, from server read only, or n servers, each machine is master
(3). (1) and (2) Beyond PHP programmer requirements, will be better, will not matter. Check for fewer indexes
(4). Write efficient SQL statements to see if there are any inefficient SQL statements, such as the full connection of the generated Cartesian product, a large number of group by and order by, no limit, and so on. When necessary, the database logic is encapsulated in the DBMS side of the stored procedure. Cache query Results, Explain of each SQL statement
(5). All that is required is to fetch only the necessary data from the database, such as querying the number of comments for an article, select COUNT (*) ... where article_id =? Yes, don't select * ... where article_id =? Then Msql_num_rows.
Send only the necessary SQL statements, such as when the article is modified, if the user only modified the title, then update ... set title =? where article_id =? Do not set content =? (large text)
(6). When necessary, use a different storage engine. For example, InnoDB can reduce deadlocks. Heap can increase query speed by an order of magnitude

8. Talk about transaction processing

A example of a $50 transfer to B's account

9, apache+mysql+php to achieve maximum load method

See 7

implementation of the text string interception of no garbled method.

Mb_substr ()

11.

<?Php
$empty=‘‘;
$null=Null;
$bool=FALSE;
$notSet;
$array =Array();
//Here are the questions
$a="Hello";
$b= & $a ;
unset $b );
$b  =  "world" ; 
// The answer is: Hello
echo  $a ?>

12.

<?Php
$empty=‘‘;
$null=Null;
$bool=FALSE;
$notSet;
$array=Array();
//Here are the questions
$a= 1 $x  = & $a $b  =  $a ++; 

//
echo  $b Span style= "color: #000000;" >;
?>

13

<?Php
$empty=‘‘;
$null=Null;
$bool=FALSE;
$notSet;
$array=Array();
//Here are the questions
$x  = empty $array Span style= "color: #000000;" >);

//
echo  $x Span style= "color: #000000;" >? "true" : "false" ;
?>


14. Write the code that shows the client IP and server IP in PHP:

Print client Ip:echo $_server[' REMOTE_ADDR ']; Or: getenv (' remote_addr ');
Print server Ip:echo gethostbyname ("http://www.baidu.com/")

PHP Face questions and Answers

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.