This section describes functions that interact with the command shell in some way. Some of them execute other programs, and two of them read or write to environment variables.
string exec(string command, array output, integer return)
The exec function attempts to execute the command argument as if you had typed it in command shell. Nothing is echoed to the browser, but the last line of output from the execution is returned. If the optional output argument is supplied, each line of output will be added to the output argument as an array element. If the optional return argument is supplied, the variable is set to the return value of the command.
It is very dangerous to put any user-supplied information inside the command argument. Users may pass values in form fields that allow them to execute their own commands on your Web server. If you must execute a command based on user input, pass the information through the escape-shellcmd function.
Compare this function to passthru and system.
string getenv(string variable)
The getenv function returns the value of the given environment variable or false if there is an error. PHP converts all environment variables into PHP variables, so this function is useful only in those rare instances when environment variables change after a script begins executing. If you need to set the value of an environment variable, use putenv.
string passthru(string command, integer return)
The passthru function is similar to exec and system. The command argument is executed as if you typed it in a command shell. If you provide the optional return argument, it will be set with the return value of the command. All output will be returned by the passthru function and sent to the browser. The output will be sent as binary data. This is useful in situations where you need to execute a shell command that creates some binary file, such as an image.
It is very dangerous to put any user-supplied information inside the command argument. Users may pass values in form fields that allow them to execute their own commands on your Web server. If you must allow this, pass the information through the escapeshellcmd function first.
The putenv function sets the value of an environment variable. You must use syntax similar to that used by a command shell, as shown in the example below. To get the value of an environment variable, use getenv, or use phpinfo to dump all environment variables.
string system(string command, integer return)
The system function behaves identically to C's system function. It executes the command argument, sends the output to the browser, and returns the last line of output. If the return argument is provided, it is set with the return value of the command. If you do not wish for the output to be sent to the browser, use the exec function.
It is very dangerous to put any user-supplied information inside the command argument. Users may pass values in form fields that allow them to execute their own commands on your Web server. If you must allow this, pass the information through the escapeshellcmd function first.<?
PHP Related Interview Questions
|PHP Interview Questions||MySQL Interview Questions|
|PHP+MySQL Interview Questions||Drupal Interview Questions|
|MYSQL DBA Interview Questions||PHP5 Interview Questions|
|WordPress Interview Questions||Joomla Interview Questions|
|CakePHP Interview Questions||CodeIgniter Interview Questions|
|PHP7 Interview Questions|
An Introduction To Php
Variables, Operators, And Expressions
Classes And Objects
I/o And Disk Access
Time, Date, And Configuration Functions
Parsing And String Evaluation
Sorting Searching And Random Numbers
Integration With Html
Efficiency And Debugging
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.