Eval in PHP and Eval__java in JavaScript

Source: Internet
Author: User
Tags parse error

The eval difference in PHP in eval and javascript:

Definition and Usage
Definitions and Usage

The eval () function evaluates a string as PHP code.
The eval () function returns a string that corresponds to the PHP code.

The string must is valid the PHP code and must end with semicolon.
This string must be valid PHP code and must end with a semicolon.

This function returns NULL unless a return statement be called in the code string. Then the value passed to return is returned. If there is a parse error in the code string, eval () returns FALSE.
In addition to requesting "return statement [statement]" in the code string, in other cases, this function returns a null value [NULL], and if a return statement is requested, it returns the value that is passed to the return statement. If this code string has an error, the eval () function returns FALSE.

Eval () function, which can execute a string as a JavaScript expression.

You can convert the form of a string to a numeric type, etc.





Ob_start () Ob_end_clean () ob_get_contents ()

(2008-12-19 16:17:41) reprint

Tags: buffer start variable work ob_start ob_end_clean it Category: PHP

Use Ob_start () to output the output to the buffer instead of to the browser.
Then use ob_get_contents to get the buffer area data.

Ob_start () opens a buffer on the server to hold all the output. So at any time using echo, the output will be added to the buffer until the program runs out or ends with Ob_flush (). The contents of the buffer in the server are then sent to the browser, which is parsed by the browser.

Function Ob_end_clean clears the contents of the buffer and closes the buffer, but does not output the content.
At this point you have to use a function ob_get_contents () before the Ob_end_clean () to get the contents of the buffer.
In this way, you can save the content in a variable before executing ob_end_clean (), and then do the same with the variable after Ob_end_clean ().

This is eg:

Ob_start (); Buf1
echo ' multiple ';
Ob_start (); Buf2
Echo ' buffers work ';
$buf 2 = ob_get_contents ();
Ob_end_clean ();
$buf 1 = ob_get_contents ();
Ob_end_clean ();

echo $buf 1;
Echo ' <br/> ';
echo $buf 2;



function Format_js ($string, $isjs) {$string = addslashes (Array ('/n ', '/R '), Array (', '), $string)); return $ISJS? ' Document.wirte ("$string"); ': $string; }

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.