Logo F2FInterview

Php Advanced Interview Questions

Q   |   QA

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

The session support can be turned on automatically at the site level, or manually in each PHP page script:

  • 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.

Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.

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.

session_id() returns the session id for the current session.

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: