www.pickatutorial.com Computer Tutorials
Top eBooks: C/C++ | C# | Android | Mathematics | Database | Cloud | Graphics | Networking | Oracle | Hardware | AI
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons PHP Application Functions Bookmark and Share
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27
Lesson 28
Lesson 29
Lesson 30
Lesson 31
Lesson 32
Lesson 33
Lesson 34
Lesson 35
Lesson 36
Lesson 37
Lesson 38
Lesson 39
Lesson 40
Lesson 41
Lesson 42
Lesson 43
Lesson 44
PHP Application functions are very useful for a developer building a real world PHP application. In the following text some of the most useful PHP Application functions are discussed:

The die() function outputs a given message and terminates the PHP script. Its syntax follows:

We often use the following code to print a message and stop the execution of our script upon the failure to connect to the database:

$connection = mysql_connect("servername", "user", "password") or die ("Database Error! Can't connect to database.");

The exit statement is used to terminate the execution of the current PHP script at the point where the exit statement is used.

sleep() and usleep()
The sleep() and usleep() functions, when called, put a pause, or a delay, at a given point in the execution of our PHP code. The syntax of these functions follows:

sleep(seconds); usleep(microseconds);

The only difference between sleep() and usleep() is that the given wait period for sleep() is in seconds, and the wait period for usleep() is in microseconds.

Program Execution Functions
PHP’s built-in program execution functions are used to execute programs residing on our system, such as encryption programs, third-party image manipulation programs, and so forth. It is important for all program execution functions that the PHP user must have proper permissions to execute the given program(s).

The exec() function is used to execute an external program as follows:

exec(command, [array], [return_var]);

If an array is specified, the output of the exec() function will append to the array. If return_var is specified, it will be assigned a value of the program’s return status. The syntax of the exec() function follows:

$command = "ping www.pickatutorial.com";
exec($command, $result, $rval);

passthru() Just like the exec() function, the passthru() function is also used to execute an external program. The only difference between the two is that passthru() returns the raw output of the action. The syntax follows:

passthru(command, return_var);

The system() function is also used to execute an external program and display output as the command is being executed. The sysntax follows:

system(command, [return_var]);

If return_var is specified, it will be assigned a value of the program's return status.

Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.