Change language

PHP Eval () function

Syntax:
eval ($string) 
Parameters:This function takes one parameter, as shown in the following above syntax and described below.
  • $string:it must be valid PHP code to evaluate, but must not contain opening and closing PHP tags.
Note.All statements must be properly terminated with a semicolon. For example, initializing the string as "echo" Geeks for Geeks "" will cause a parsing error. To fix, you need to initialize as "echo" Geeks for Geeks ";".Return value:Returns NULL if no return statement is invoked on an input string containing PHP code. Then the value is returned. If a parsing error occurs in the input string, the function returns FALSE.Examples :
Input: $age = 20; $str = "I am $age years old" eval ("$str =" $str ";"); Output: I am 20 years old Input: $str = ’echo" Geeks for Geeks ";’; echo eval ($str). ""; Output: Geeks for Geeks 
The programs below illustrate the use of the eval() function:Program 1: $age = 20; $str = ’My age is $age’ ; echo $str . "" ; eval ( " $str = "$str"; " ); echo $str . "" ; ?> Exit:
My age is $age My age is 20 
Program 2: $str = ’echo" Geeks for Geeks ";’ ; echo eval ( $str ). "" ; ?> Exit:
Geeks for Geeks 
Link: http: // php. net / manual / en / function.eval.php

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method