You can get the location of php.ini by using <?php phpinfo(); ?> code.
Question #2: How to POST Data using CURL in PHP?
you can execute POST data by using CURL as below :
$data = array('name' => 'Ross', 'php_master' => true); $url = 'http://domain.com/abc.php'; // You can POST a file by prefixing with an @ (for <input type="file"> fields) $handle = curl_init($url); curl_setopt($handle, CURLOPT_POST, true); curl_setopt($handle, CURLOPT_POSTFIELDS, $data); curl_exec($handle); curl_close($handle);
Question #3: How to get duplicate values from array?
you can get duplicate values from an array by using array_diff_assoc($arr, $arr_unique); for an example :
<php$arr = ('anil','anil','sonia','monica','sunita','sunita','raj');$arr_unique = array_unique($arr);$arr_duplicates = array_diff_assoc($arr, $arr_unique);print_r($arr_duplicates);?>
It will return :
Array([1] => anil
[2] => sunita
)
Question #4: How to identify server IP address in PHP?
you can identify server IP address by using $_SERVER['SERVER_ADDR'];
Question #5: What is the difference between explode() and split() functions?
Split function splits string into array by regular expression. Explode splits a string into array by string.
Both function are used to breaks a string into an array, the difference is that Split() function breaks split string into an array by regular expression and explode() splits a string into an array by string. explode() is faster than split() because it does not match the string based on regular expression.
Question #6: What is difference between require_once(), require() and include() function ?
require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.
Header() function is mostly used to Redirect from one page to another -
<?php header("Location:page.php"); ?>
Question #8: What type of inheritance does not support by PHP ?
Only Multiple Inheritance does not support by PHP.
Question #9: What is PEAR?
PEAR stands for PHP Extension and Application Repository. PEAR is a framework and repository for re-usable PHP components.
Question #10: What are different types of errors in PHP ?
- E_WARNING: It is a run-time warning that does not cause script termination.
- E_ERROR: It is a fatal error that causes script termination.
- E_NOTICE: It is a run time notice caused due to error in code.
- E_CORE_WARNING: Warnings that occur during PHP's initial startup.
- E_PARSE: Compile time parse error.
- E_CORE_ERROR: It is a fatal errors that occur during PHP's initial startup
- E_COMPILE_ERROR: Fatal compile-time errors indication problem with script.
- E_USER_WARNING: It is a user-generated warning message.
- E_USER_NOTICE: User-generated notice message.
- E_USER_ERROR: User-generated error message.
- E_STRICT: Run-time notices.
- E_RECOVERABLE_ERROR: It is a catchable fatal error indicating a dangerous error
- E_ALL: Catches all errors and warnings
Question #11 - Write down the code for save an uploaded file in php.
if ($_FILES["file"]["error"] == 0) {
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; }
Question #12 - How to create a text file in php?
$filename = "/home/user/guest/newfile.txt"; $file = fopen( $filename, "w" ); if( $file == false ) { echo ( "Error in opening new file" ); exit(); } fwrite( $file, "This is a simple test\n" ); fclose( $file );
Note: Only a member of this blog may post a comment.