Complete Book of PHP,Javascript and CSS
Click here to Download this File PHP_BOOKs
Is PHP limited to process GET and POST request methods only?
No, it is possible to handle any request method, e.g. CONNECT. Proper response status can be sent with header(). If only GET and POST methods should be handled, it can be achieved with this Apache configuration:
<LimitExcept GET POST> Deny from all </LimitExcept>
How do I add my PHP directory to the PATH on Windows?
On Windows NT+ and Windows Server 2000+:
On Windows 98/Me you need to edit the autoexec.bat file:
Note: Be sure to reboot after following the steps above to ensure that the PATH changes are applied.
The PHP manual used to promote the copying of files into the Windows system directory, this is because this directory (C:\Windows, C:\WINNT, etc.) is by default in the systems PATH. Copying files into the Windows system directory has long since been deprecated and may cause problems.
Yes, using the mail() function of PHP, HTML emails can be sent. The content type header must be mentioned.
<?php
// multiple recipients
$to = ‘example@example.com’
// subject
$subject = ‘HTML email’;
// message
$message = ‘
<html>
<head>
<title>HTML EMAIL</title>
</head>
<body>
<p>Sample of HTML EMAIL!</p>
</body>
</html>
‘;
// To send HTML mail, the Content-type header must be set
$headers = ‘MIME-Version: 1.0’ . “\r\n”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;
// Additional headers
$headers .= ‘To: Joe <joe@example.com>, Kelly <kelly@example.com>’ . “\r\n”;
$headers .= ‘From: HTML EMAIL <sample@example.com>’ . “\r\n”;
$headers .= ‘Cc: samplecc@example.com’ . “\r\n”;
// Mail it
mail($to, $subject, $message, $headers);
?>
JavaScript can be inserted by specifying the language as:-
<?
<script language=’javascript’>
Code goes here
</script>
?>
PHP supports single inheritance. Using the extend keyword A class can inherit methods and members of another base class (only one).It will not support multiple inheritance.
Random number is generated by using the function rand(),mt_rand(). If the function is used without sending a parameter, a random number between 0 and RAND_MAX is returned.
Ex. echo rand();
To return a random number between 120 and 200 inclusive, the code snippet is
echo rand(120,200);
For returning a random number using the Mersenne Twister algorithm, use mt_rand().
The function srand() is used to seed the random number, and it must be used once in a script and before the rand() function. If the randomness of the seed is greater, more random numbers can be generated.
Ex.
srand((double)microtime()*1000000);
echo rand(0,100);
The users IP address can be returned by specifying the host name as aparameter in gethostbyname(“hostname”) method.
Example:
<?php
$ip = gethostbyname(‘www.sample.com’);
echo $ip;
?>