Skip to main content

Openings for different technoogies.

PHP Interview questions 2

1) How we load all classes that placed in different directory in one PHP File , means how to do auto load classes
Ans :      by using spl_autoload_register('autoloader::funtion');
Like below
class autoloader
{
public static function moduleautoloader($class)
{
$path = $_SERVER['DOCUMENT_ROOT'] . "/modules/{$class}.php";
if (is_readable($path)) require $path;
}
public static function daoautoloader($class)
{
$path = $_SERVER['DOCUMENT_ROOT'] . "/dataobjects/{$class}.php";
if (is_readable($path)) require $path;
}
public static function includesautoloader($class)
{
$path = $_SERVER['DOCUMENT_ROOT'] . "/includes/{$class}.php";
if (is_readable($path)) require $path;
}
}
spl_autoload_register('autoloader::includesautoloader');
spl_autoload_register('autoloader::daoautoloader');
spl_autoload_register('autoloader::moduleautoloader');

2) How many types of Inheritances used in PHP and how we achieve it
Ans :      As far PHP concern it only support single Inheritance in scripting.
we can also use interface to achieve multiple inheritance.
                 
3)          PHP how to know user has read the email?
Ans :      Using Disposition-Notification-To: in mailheader we can get read receipt.
Add the possibility to define a read receipt when sending an email.
It’s quite straightforward, just edit email.php, and add this at vars definitions:
var $readReceipt = null;
And then, at ‘createHeader’ function add:
if (!empty($this->readReceipt)) {
$this->__header .= ‘Disposition-Notification-To: ‘ . $this->__formatAddress($this->readReceipt) . $this->_newLine;
}

4) What are default session time and path?
Ans :      default session time in PHP is 1440 seconds or 24 minutes
Default session save path id temporary folder /tmp

5) how to track user logged out or not? when user is idle ?
Ans : 85                By checking the session variable exist or not while loading th page. As the session will exist longer as till browser closes. The default behaviour for sessions is to keep a session open indefinitely and only to expire a session when the browser is closed. This behaviour can be changed in the php.ini file by altering the line session.cookie_lifetime = 0 to a value in seconds. If you wanted the session to finish in 5 minutes you would set this to session.cookie_lifetime = 300 and restart your httpd server.

6) What is the difference between char and varchar data types?
Ans :      Set char to occupy n bytes and it will take n bytes even if u r storing a value of n-m bytes
Set varchar to occupy n bytes and it will take only the required space and will not use the n bytes
eg. name char(15) will waste 10 bytes if we store 'romharshan', if each char takes a byte eg. name varchar(15) will just use 5 bytes if we store 'romharshan', if each char takes a byte. rest 10 bytes will be free.

7) What is the functionality of md5 function in PHP?
Ans :      Calculate the md5 hash of a string. The hash is a 32-character hexadecimal number. I use it to generate keys which I use to identify users etc. If I add random no techniques to it the md5 generated now will be totally different for the same string I am using.

8) How can I load data from a text file into a table?
Ans :      you can use LOAD DATA INFILE file_name; syntax to load data from a text file. but you have to make sure thata) data is delimited
b) columns and data matched correctly

9) How can we know the number of days between two given dates using MySQL?
Ans :      SELECT DATEDIFF("2007-03-07","2005-01-01");
                 
10) How can we know the number of days between two given dates using PHP?
Ans :      $date1 = date("Y-m-d");
$date2 = "2006-08-15";
$days = (strtotime($date1) - strtotime($date2)) / (60 * 60 * 24);

Comments

Popular posts from this blog

Urgent Recruitment For Freshers And Experienced at TATA Power

Company Profile: Tata Power Solar with 25 years of deep domain expertise, is one of the pioneering solar manufacturers in the world and India's largest specialized EPC player. Reference link :http://www.tatapower.com/careers/opportunities.aspx Job Role : Graduate Trainee Job Type : Engineering jobs Job Details : At Tata Power we have a vision of where we want to go, and it’s really exciting. Would you like to be part of a company that is making history? Towards this objective, Tata Power participates in campus recruitments and is the company of choice in most major engineering institutes such as National Insitute of Technology, VJTI, Govt. Engineering Colleges, Birla Institute of Technology, NPTI, MS University, Nirma Institute of Technolgy, etc. Apart from college hiring, we also hire experienced professionals from the industry at various mid-level and senior positions. A Structured Induction Programme is carried out for: Graduate Engineer Trainees (GETs) All the GETs und...

We have the openings for Python,Django

Job Synopsis         Python / Django Openings With Symphony Teleca - Bangalore Company:         Symphony Experience:      5 to 10 yrs Location:         Bengaluru/Bangalore Job Description         Work Location: Bangalore (ITPL) Experience: 2-10 Yrs (SE, SSE, Lead, Architect/Manager) Mandatory Skills: Django 1.3.3 Python 2.6 Mysql 5.1 / Postgres 9.1 / any other DB Optional Skills: Celery 3.0.5, Httpd, Nginx, Memcache, Jquery Please revert with your updated CV's ASAP. Regards, Deepthi. Role:                         Team Lead/Technical Lead Role Category:         Programming & Design Industry Type:         IT-Software / Software Services Functiona...

Walk in at HCL Technologies Limited for Technical Support Executive On 3rd to 7th Dec

Company        HCL Technologies Limited Website          www.hcl.com Eligibility        Any Graduates Experience     0-1 Year Location         Chennai HCL Technologies Limited Job Role: Technical Support Executive - 100 Opening(s) Job Summary : Provides technical assistance and training to customers by performing the following duties. Essential Duties and Responsibilities: include the following. Other duties may be assigned as required. Provide client support and technical issue resolution via E-Mail, phone and other electronic medium. Configuration of client's equipment to connect to the Internet via modem/DSL Router (Dialup/DSL customers only). Configure software to connect to Internet application servers. Provide training to clients in the use of system and applications as related to Internet. Obtain general und...