Category: PHP

Top PHP Interview questions – 06

801. .How would you break up a delimited string into an array of substrings? 802. What regular expression syntax would you use to match the letter”b” at ;least once but not more than six...

Top PHP Interview questions – 05

500. when calling urls from a mysql database how do you make them active links on screen in php 501. How do I change this into a link? <?php echo $row_rsLocations [&#39;CODE&#39;] ; ?>...

Top PHP Interview questions – 04

401. How can i include a PHP PAGE on a non-php server?… I mean i want include a SIMPLE php page… 402. Why can&#39;t I get PHPSESSID to work (PWS on NT WorkStation 4.0,...

Top PHP Interview questions – 03

201. What is the PHP equivelent of ColdFusion&#39;s <CFHTTP> tag? (Both GET and POST operations) 202. What I do wrong to connect to a mysql DB-> Call to unsupported or undefined function mysql_connect() 203....

Top PHP Interview questions – 02

101. How do I write a php script within a php script to a file without escaping everything? 102. How can I create a dropdown for date field showing past 3 months, present month...

Top PHP Interview questions – 01

1. What Is PHP ? 2. How can I disable the output of error messages inside the HTML page? 3. Can I return other file formats (like Word, Excel, etc) using PHP? 4. Is...

Php Interview Questions and Answers -16

How to store the uploaded file to the final location? move_uploaded_file ( string filename, string destination) This function checks to ensure that the file designated by filename is a valid upload file (meaning that...

Php Interview Questions and Answers -15

How can I set a cron and how can I execute it in Unix, Linux, and windows? Cron is very simply a Linux module that allows you to run commands at predetermined times or...

Php Interview Questions and Answers -14

How can increase the performance of MySQL select query? We can use LIMIT to stop MySql for further search in table after we have received our required no. of records, also we can use...

Php Interview Questions and Answers -13

What is maximum size of a database in mysql? If the operating system or filesystem places a limit on the number of files in a directory, MySQL is bound by that constraint. The efficiency...

Php Interview Questions and Answers -12

What is the use of friend function? Friend functions Sometimes a function is best shared among a number of different classes. Such functions can be declared either as member functions of one class or...

Php Interview Questions and Answers -11

How to reset/destroy a cookie ? Reset a cookie by specifying expire time in the past: Example: setcookie(‘Test’,$i,time()-3600); // already expired time Reset a cookie by specifying its name only Example: setcookie(‘Test’); What types...

Php Interview Questions and Answers -10

Who is the father of PHP and what is the current version of PHP and MYSQL? Rasmus Lerdorf. PHP 5.1. Beta MySQL 5.0 In how many ways we can retrieve data in the result...

Php Interview Questions and Answers -09

How can we know that a session is started or not? A session starts by session_start() function. This session_start() is always declared in header portion. it always declares first. then we write session_register(). What...

Php Interview Questions and Answers -08

Give the syntax of REVOKE commands? The generic syntax for revoke is as following REVOKE [rights] on [database] FROM [username@hostname] Now rights can be: a) ALL privileges b) Combination of CREATE, DROP, SELECT, INSERT,...

Php Interview Questions and Answers -07

How can we destroy the session, how can we unset the variable of a session? session_unregister() – Unregister a global variable from the current session session_unset() – Free all session variables What are the...

Php Interview Questions and Answers -06

How can we register the variables into a session? session_register($session_var); $_SESSION[‘var’] = ‘value’; What is the difference between characters \023 and \x23?  The first one is octal 23, the second is hex 23. With...

Time Ago Function in php

This can be used for comments and other from of communication to tell the time ago instead of the exact time which might not be correct to some one in another time zone. The...

How to Unzip Files using php?

<?php $zip = zip_open(“zip.zip”); if (is_resource($zip)) { while ($zip_entry = zip_read($zip)) { $fp = fopen(“zip/”.zip_entry_name($zip_entry), “w”); if (zip_entry_open($zip, $zip_entry, “r”)) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); fwrite($fp,”$buf”); zip_entry_close($zip_entry); fclose($fp); } } zip_close($zip); } ?>

Php Interview Questions and Answers -05

Why doesn’t the following code print the newline properly? <?php $str = ‘Hello, there.\nHow are you?\nThanks for visiting techpreparation’; print $str; ?> Because inside the single quotes the \n character is not interpreted as...

Php Interview Questions and Answers -04

What is the difference between ereg_replace() and eregi_replace()? eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters. How do I find out the number of parameters passed...

Php Interview Questions and Answers -03

Would I use print “$a dollars” or “{$a} dollars” to print out the amount of dollars in this example? In this example it wouldn’t matter, since the variable is all by itself, but if...

Php Interview Questions and Answers -02

How do you define a constant? Via define() directive, like define (“MYCONSTANT”, 100); What are the differences between require and include, include_once?  Anwser 1: require_once() and include_once() are both the functions to include and...

Php Interview Questions and Answers -01

What’s PHP ? The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications. What...

How to Get Image Information using PHP?

/* * @param string $file Filepath * @param string $query Needed information (0 = width, 1 = height, 2 = mime-type) * @return string Fileinfo */ function getImageinfo($file, $query) { if (!realpath($file)) { $file...

How to Get Users IP Address using PHP code?

Accounts for proxies: if (!empty($_SERVER[‘HTTP_CLIENT_IP’])) { $ip=$_SERVER[‘HTTP_CLIENT_IP’]; } elseif (!empty($_SERVER[‘HTTP_X_FORWARDED_FOR’])) { $ip=$_SERVER[‘HTTP_X_FORWARDED_FOR’]; } else { $ip=$_SERVER[‘REMOTE_ADDR’]; }