Php

PHP Function:  Built-in Functions part 9

PHP Function: Built-in Functions part 9

Fadıl

Program Execution Functions
You can use PHP’s built in program execution functions to use programs residing on your system, such as encryption programs, third-party image manipulation programs, and so forth. For all program execution functions, the PHP user much have permission to execute the given program.

exec()
The exec() function executes an external program. its syntax is

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.

PHP Function:  Built-in Functions part 8

PHP Function: Built-in Functions part 8

Fadıl

Misc. Functions

The die() and exit functions provide useful control over the execution of your script, offereing an ‘escape route’ for programming errors.

die()
Outputs a given message and terminates the script when a returned value is false. Its syntax is

die(“message”);

for example, you would use the following code to print a message and stop the execution of your script upon failure to connect to your database:

$connection = mysql_connect(“servername”, “username”, “password”)
or die(“Can’t connect to database.”);

PHP Function:  Built-in Functions part 7

PHP Function: Built-in Functions part 7

Fadıl

Here are yet more Built-in Functions,

Mail Function
If your server has access to sendmail or an SNMP gateway the mail() function sends mail to a specified recipient. Its syntax is

mail(“recipient”, “subject”, “message”, “mail headers”);

For example, the following code sends mail to [email protected] with the subject of “Great Site” and a message body saying “Techsoftcenter.com Is a cool site!”. The “From:” line is part of the additional mail headers.

PHP Function:  Built-in Functions part 6

PHP Function: Built-in Functions part 6

Fadıl

Today in Buit-in Funtions we will look at some HTTP functions.

header()
The header() function outputs an HTTP header string, such as a location redirection. This output must occur before any other data is sent to the browser, including HTML tags. For example to use the header() function to redirect a user to a new location, use this code:

header(“Location: http://www.techsoftcenter.com”);
exit;
(TIP – Follow a header() statement with the exit command. This ensures that the code does not continue to execute.)

PHP Function:  Built-in Functions part 5

PHP Function: Built-in Functions part 5

Fadıl

Welcome back to Built-in Functions.

Filesytem Functions
chmod(), chgrp(), chown()
Like the shell commands of the same name, the chmod(), chgrp(), and chown() functions modify the permissions, grop and owner of a directory or file. Here is the syntax of these functions:

chmod(“filename”, mode);
chmgrp(“filename”, newsgroup);
chown(“filename”, newowner);
In order to change permissions, groups, or owners, the PHP user must be the owner of the file, or the permissions must already be set to allow such change by that user.