Faqs
Faqs for all web development languages
How many ways can we get the value of current session id?
Dec 8th
session_id() returns the session id for the current session.
What’s the difference between include and require?
Dec 8th
It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
Explain the ternary conditional operator in PHP?
Dec 8th
Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.
How can I embed a java programme in php file and what changes have to be done in php.ini file?
Dec 8th
There are two possible ways to bridge PHP and Java: you can either integrate PHP into a Java Servlet environment, which is the more stable and efficient solution, or integrate Java support into PHP. The former is provided by a SAPI module that interfaces with the Servlet server, the latter by this Java extension. 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.
Example Code:
getProperty(‘java.version’) . ”; echo ‘Java vendor=’ . $system->getProperty(‘java.vendor’) . ”; echo ‘OS=’ . $system->getProperty(‘os.name’) . ‘ ‘ More >
Explain about Type Juggling in php?
Dec 8th
PHP does not require (or support) explicit type definition in variable declaration; a variable’s type is determined by the context in which that variable is used. That is to say, if you assign a string value to variable $var, $var becomes a string. If you then assign an integer value to $var, it becomes an integer.
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 More >
How to store the uploaded file to the final location?
Dec 8th
move_uploaded_file ( string filename, string destination)
This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP’s HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.
If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.
If filename is a valid upload file, but cannot be moved for some reason, no action will occur, and move_uploaded_file() will return FALSE. Additionally, a warning will be issued.
What is the difference between Reply-to and Return-path in the headers of a mail function?
Dec 8th
Reply-to: Reply-to is where to delivery the reply of the mail.
Return-path: Return path is when there is a mail delivery failure occurs then where to delivery the failure notification.
List out different arguments in PHP header function?
Dec 8th
void header ( string string [, bool replace [, int http_response_code]])
What type of headers have to be added in the mail function to attach a file?
Dec 8th
$boundary = ‘–’ . md5( uniqid ( rand() ) ); $headers = “From: \”Me\”\n”; $headers .= “MIME-Version: 1.0\n”; $headers .= “Content-Type: multipart/mixed; boundary=\”$boundary\”";
How many ways I can redirect a PHP page?
Dec 8th
Here are the possible ways of php page redirection.
1. Using Java script: ‘; echo ‘window.location.href=”‘.$filename.’”;’; echo ”; echo ”; echo ”; echo ”; } } redirect(‘http://maosjb.com’); ?>
2. Using php function: header(“Location:http://maosjb.com “);