If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b?Is it possible to set a time expire page in PHP?How can I embed a java programme in php file and what changes have to be done in php.ini file?Explain the purpose of output buffering in PHP.List out different arguments in PHP header function?How do I find out the number of parameters passed into function ?What Are the File Upload Settings in Configuration File?How can you access a COM object from a PHP page?How can we know the count/number of elements of an array?How session works (internal processing of session)?How many ways I can redirect a PHP page?How can I turn off MySQL strict mode? or Solving Incorrect integer value problem with MySQL 5 strict-modeExplain the changing file permission and ownership using PHP's chmod() function.Explain the difference between ereg_replace() and eregi_replace(). ~ Interview Questions & Answers

Wednesday, November 3, 2010

If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b?

5, it’s a reference to existing variable.

Tuesday, August 3, 2010

Is it possible to set a time expire page in PHP?

Yes it is Using header("Expires: Mon, 26 Jul 2007 05:00:00 GMT");<?php header("Expires: Mon, 26 Jul 2007 05:00:00 GMT"); ?>

How can I embed a java programme in php file and what changes have to be done in php.ini file?

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') . ' ' . $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 behaviour of these functions is affected by settings in php.ini.
Table 1. Java configuration options
Name
Default
Changeable
java.class.path
NULL
PHP_INI_ALL
Name Default Changeable
java.home
NULL
PHP_INI_ALL
java.library.path
NULL
PHP_INI_ALL
java.library
JAVALIB
PHP_INI_ALL

Sunday, June 27, 2010

Explain the purpose of output buffering in PHP.

Output buffering in PHP buffers a scripts output. This buffer can be edited before returning it to the client. Without output buffering, PHP sends data to the web server as soon as it is ready. Output buffering "send" cookies at any point in the script. Cookies do not have to be necessarily sent near the start of page. Output buffers are stackable and hence sending to output is by choice.

Friday, June 18, 2010

List out different arguments in PHP header function?

void header ( string string [, bool replace [, int http_response_code]])

Sunday, June 13, 2010

How do I find out the number of parameters passed into function ?

func_num_args() function returns the number of parameters passed in.

Tuesday, June 8, 2010

What Are the File Upload Settings in Configuration File?

There are several settings in the PHP configuration file related to file uploading:
• file_uploads = On/Off - Whether or not to allow HTTP file uploads.
• upload_tmp_dir = directory - The temporary directory used for storing files when doing file upload.
• upload_max_filesize = size - The maximum size of an uploaded file.

Saturday, June 5, 2010

How can you access a COM object from a PHP page?

By utilizing the com_load and the dotnet_load respectively
you can incorporate COM objects and .NET libraries into your
PHP code, thus anytime you see "library code" in a question,
make sure you remember these two functions.
com_load — Creates a new reference to a COM component [deprecated]
Deprecated, use the OO syntax instead.
<?php
// do this
$obj = new COM($module);
// instead of this:
$obj = com_load($module);
?>

How can we know the count/number of elements of an array?

2 ways:
a) sizeof($array_name) - This function is an alias of count()
b) count($array_name) - This function returns the number of elements in an array.
Interestingly if you just pass a simple var instead of an array, count() will return 1.

Thursday, June 3, 2010

How session works (internal processing of session)?

To start a session:
– session_start()
– Creates a session identifier
– Session identifier is passed between client and server either as a Cookie, or in GET parameters
Then, can create, access, and modify session variables:
– $_SESSION[session_var_name] = value;
– $_SESSION is only available once you call session_start()
– $local_variable = $_SESSION[session_var_name];
– Can check if session variable is set by using isset();
To end a session:
– session_destroy();

How many ways I can redirect a PHP page?

a. Header function in PHP redirects to a new URL
Example:
<?php
header("Location: http://www.redirecturl.com/");
?>
b. http_redirect() is also used to redirect to a new page or URL.
Syntax
void http_redirect ( [string url [, array params [, bool session = FALSE [, int status]]]] )
Here, the URL is the path of the new page. params can be some query parameters followed by whether the session information needs to be passed and the custom response status code.

Wednesday, February 10, 2010

How can I turn off MySQL strict mode? or Solving Incorrect integer value problem with MySQL 5 strict-mode


This can be done in two ways...
Open your "my.ini" (my.cnf in linux) file within the MySQL installation directory, and look for the text "sql-mode".
Find:
# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Replace with:
# Set the SQL mode to strict
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Or, you can run an SQL query within your database management tool, such as phpMyAdmin:
SET @global.sql_mode= '';

Friday, February 5, 2010

Explain the changing file permission and ownership using PHP's chmod() function.

Chmod() is used for changing permissions on a file.
Syntax:
Chmod(file, mode)
Mode here specifies the permissions as follows:
* The first number is always zero
* The second number specifies permissions for the owner
* The third number specifies permissions for the owner's user group
* The fourth number specifies permissions for everybody else
Possible values (to set multiple permissions, add up the following numbers)
* 1 = execute permissions
* 2 = write permissions
* 4 = read permissions
Example:
// everything for owner, read for owner's group
chmod("test.txt",0740);

Sunday, January 3, 2010

Explain the difference between ereg_replace() and eregi_replace().

ereg_replace() is used for matching patters to the input string. It then replaces the matched string.

SYNTAX
string ereg_replace ( string $pattern , string $replacement , string $string )
eregi_replace() is used for matching patters to the input string. It then replaces the matched string. The difference is that this function is case sensitive.