Basic PHP Programming Questions and Answers
PHP Questions and Answers: Submit Your Question
Be the First to add answer.
Post Your Answer Now
$file = file_get_contents("/windows/system32/drivers/etc/services");
print("Size of the file: ".strlen($file)."n");
This script will print:
Size of the file: 7116
|Is This Answer Correct?||11 Yes||4 No|
|Is This Answer Correct?||19 Yes||2 No|
|Is This Answer Correct?||17 Yes||0 No|
|Is This Answer Correct?||15 Yes||1 No|
* Turning on session support automatically at the site level: Set session.auto_start = 1 in php.ini.
* Turning on session support manually in each page script: Call session_start() funtion.
|Is This Answer Correct?||12 Yes||1 No|
The Java extension provides a simple and effective means for creating and invoking methods on Java objects from PHP. The JVM is created using JNI, and everything runs in-process.
getProperty('java.version') . ''; echo 'Java vendor=' . $system->getProperty('java.vendor') . ''; echo 'OS=' . $system->getProperty('os.name') . ' ' . $system->getProperty('os.version') . ' on ' . $system->getProperty('os.arch') . ' '; // java.util.Date example $formatter = new Java('java.text.SimpleDateFormat', "EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz"); echo $formatter->format(new Java('java.util.Date')); ?>
The behavior of these functions is affected by settings in php.ini.
Table 1. Java configuration options
Name Default Changeable
An example of PHP's automatic type conversion is the addition operator '+'. If any of the operands is a float, then all operands are evaluated as floats, and the result will be a float. Otherwise, the operands will be interpreted as integers, and the result will also be an integer. Note that this does NOT change the types of the operands themselves; the only change is in how the operands are evaluated.
$foo += 2; // $foo is now an integer (2)
$foo = $foo + 1.3; // $foo is now a float (3.3)
$foo = 5 + "10 Little Piggies"; // $foo is integer (15)
$foo = 5 + "10 Small Pigs"; // $foo is integer (15)
If the last two examples above seem odd, see String conversion to numbers.
If you wish to change the type of a variable, see settype().
If you would like to test any of the examples in this section, you can use the var_dump() function.
Note: The behavior of an automatic conversion to array is currently undefined.
Since PHP (for historical reasons) supports indexing into strings via offsets using the same syntax as array indexing, the example above leads to a problem: should $a become an array with its first element being "f", or should "f" become the first character of
Return-path: Return path is when there is a mail delivery failure occurs then where to delivery the failure notification.
|Is This Answer Correct?||4 Yes||0 No|
$headers = "From: "Me"n";
$headers .= "MIME-Version: 1.0n";
$headers .= "Content-Type: multipart/mixed; boundary="$boundary"";