|
1.Explain parse Errors? What are the most common causes of parce errors? The most common category of error arises from mistyped or syntactically incorrect PHP code, which confuses the PHP parsing engine.
1)The missing semicolon ***********************
If each PHP instruction is not duly finished off with a semicolon, a parse error will result. In this sample fragment, the first line lacks a semicolon and, therefore, the variable assignment is never completed. What we have here is
<?php $Problem = “a silly misunderstanding” echo $Problem; ?> 2)No dollar signs *******************
Another very common problem is that a dollar sign prepending a variable name is missing.If the dollar sign is missing during the initial variable assignment, like so:
What we have here is <?php Problem = “a big ball of earwax”; echo $Problem; ?>.
A parse error message will result. However, if instead the dollar sign is missing from a later output of the variable, like this:
What we have here is <?php $Problem = “a big ball of earwax”; print(“Problem”); ?> 2.What are the ‘function problems’ you have met in php? 1)Call to undefined function we_w3answers() *****************************************
PHP is trying to call the function we_w3answers(), which has not been because you misspelled the name of a function (built-in or user-defined) simply omitted the function definition. If you use include/require functions, make sure that you are loading the appropriate files.
2)Call to undefined function array() *********************************** This problem has a cause that is similar to the cause of the previous problem, although it still baffled us completely the first time we ran into it. It can arise when you have code like the following: $my_w3answers= array(); $my_w3answers(5) = “the fifth”; 3)Cannot redeclare my_function() ******************************* This is a simple one—somewhere in your code you have two definitions of my_function(), which PHP will not stand for.
Make sure that you are not using include to pull in the same file of function definitions more than once. Use include_once or require_once to avoid
4)Wrong parameter count *********************** 3.Will persistent connection work in the CGI version of php? Persistent database connections work only in the module installation of PHP. If you ask for a persistent connection in the CGI version, you will simply get a regular connection. 4.What is the process that takes place when you upload a file in php? There are two basic things covered here.
The form that will be used to post the file data to and the actual program that does the uploading. Further we will discuss the method that PHP itself suggests for uploading files. 5.List out some session function in php? session_save_path -- Get and/or set the current session save path session_is_registered -- Find out whether a global variable is registered in a session session_unset -- Free all session variables session_cache_expire -- Return current cache expire session_cache_limiter -- Get and/or set the current cache limiter session_commit -- Alias of session_write_close() session_decode -- Decodes session data from a string session_destroy -- Destroys all data registered to a session session_write_close -- Write session data and end session session_encode -- Encodes the current session data as a string session_get_cookie_params -- Get the session cookie parameters session_id -- Get and/or set the current session id session_module_name -- Get and/or set the current session module session_name -- Get and/or set the current session name session_regenerate_id -- Update the current session id with a newly generated one session_register -- Register one or more global variables with the current session session_set_cookie_params -- Set the session cookie parameters 6.what is meant by persistent database connections? Persistent connections are links that do not close when the execution of your script ends. When a persistent connection is requested, PHP checks if there's already an identical persistent connection (that remained open from earlier) - and if it exists, it uses it. If it does not exist, it creates the link. An 'identical' connection is a connection that was opened to the same host, with the same username and the same password (where applicable). 7.How many ways your web server can utilize PHP to generate web pages? Mainly there are three ways ***************************
The first method is to use PHP as a CGI "wrapper". When run this way, an instance of the PHP interpreter is created and destroyed for every page request (for a PHP page) to your web server. Because it is destroyed after every request, any resources that it acquires (such as a link to an SQL database server) are closed when it is destroyed. In this case, you do not gain anything from trying to use persistent connections -- they simply don't persist. 8.How to opening excel files in windows nad linux using php? f you're using PHP on Windows, you can use the inbuilt COM library $excel = new COM("excel.application"); $excel->Workbooks->Open("filename.xls"); On Linux machines, is PHPExcelReader( download from sourceforgr.net), and it seems to work very efficiently and easily with only a few lines of code. $data = new Spreadsheet_Excel_Reader(); $data->read("filename.xls"); And you can access the data with a simple loop: for($i=1; $i <= $data->sheets[0]['numRows']; $i++) { echo 'Row '. $i .', Column a:' $data->sheets[0]['cells'][$i][1] . '<br />'; echo 'Row '. $i .', Column b:' $data->sheets[0]['cells'][$i][2] . '<br />'; } 9.what are the ways to check image mime type in php?
There are a few inbuilt options you can use however, for example getimagesize() can return the mimetype, as does some of the new fileinfo functions. The mime type in getimagesize is stored in 'mime', and can be accessed as shown below. 10.Given a line of text $string, how would you write a regular expression to strips all the html tag from it?
$stringOfText = "<p>This is a test</p>"; $expression = "/<(.*?)>(.*?)<\/(.*?)>/"; echo preg_replace($expression, "\\2", $stringOfText);
|