Technical Interview Questions

Recent Question and Answers

$stringOfText = "<p>This is a test</p>"; $expression = "/<(.*?)>(.*?)<\/(.*?)>/"; echo preg_replace($expression, "\\2", $stringOfText); ....! A. preg_replace() B. str_replace() C. str_ireplace() D. substr_replace() Answer B is correct. The PHP efficiency mantra is “do no more work than necessary.” Both str_ireplace() and preg_replace() have more expensive (and flexible) matching logic, so you should only use them when your problem requires it. substr_replace() requires you to know the offsets and lengths of the substrings you want to replace, and is not sufficient to handle the t....! Asynchronous JavaScript and XML, is a web development technique for creating interactive web applications. The intent is to make web pages feel more responsive by exchanging small amounts of data with the server behind the scenes, so that the entire web page does not have to be reloaded each time the user requests a change. This is meant to increase the web page's interactivity, speed, and usability. The Ajax technique uses a combination of: * XHTML (or HTML) and CSS, for marking up and styling information.....!
1)Time triggered caching (expiry timestamp). 2)Content change triggered caching (sensitive content has changed, so cache must be updated). 3)Manually triggered caching (manually inform the application that information is outdated, and force a new cache creation). ....! SELECT CURTIME(); SELECT CURDATE(); SELECT CURRENT_TIME(); SELECT CURRENT_DATE(); ....! <?php echo 'Hello World'; ?> ....!
mod_rewrite*************Simply, mod_rewrite is used for rewriting a URL at the server level, giving the user output for that final page. So, for example, a user may ask for http://www.referads.com/example/blue/, but will really be given http://www.referads.com/example.php?colour=blue by the server. Of course, the user will b....! MySQL (pronounced "my ess cue el") is an open source relational database management system (RDBMS) that uses Structured Query Language (SQL), the most popular language for adding, accessing, and processing data in a database. Because it is open source, anyone can download MySQL and tailor it to their needs in accordance with the general public license. MySQL is noted mainly for its speed, reliability, and flexibility Memcache is a technology which caches objects in memory where your web application can get to them really fast. It is used by sites such as Digg.com, Facebook.com and NowPublic.com and is widely recognized as an essential ingredient in scaling any LAMP application to handle enormous traffic.   ....! In computing, phishing is a form of criminal activity using social engineering techniques. It is characterized by attempts to fraudulently acquire sensitive information, such as passwords and credit card details, by masquerading as a trustworthy person or business in an apparently official electronic communication. Phishing is typically carried out using email or an instant message. The term phishing derives from password harvesting and the use of increasingly sophisticated lures to "fish" for users' financial information and passwords. <?php $file_rimg = fopen("http://w3answers /image23.jpg",'rb'); $newfile_name_img = "/tmp/tutorial.file"; $file_wnew = fopen($newfile_name_img,'wb'); while (!feof($file_rimg)) { $chunk_rd = fread($file_rimg,1024); fwrite($file_wnew,$chunk_rd); } fclose($file_wnew); fclose(file_rimg); ?> www.w3answers.com ....! www.w3answers.com 1. Object oriented PHP code is much more reusable because by its' very nature, it is modular. 2. Object oriented PHP is easier to update. Again, because PHP code is organised into objects. 3. Object oriented PHP makes team programming much easier to manage. 4. Object oriented PHP makes larger projects much easier to manage. 5. Object oriented PHP makes creating code libraries much easier. ....! * Anything from a form* Anything from $_GET, $_POST, $_REQUEST* Cookies ($_COOKIES)* Web services data* Files* Some server variables (e.g. $_SERVER['SERVER_NAME'])* Environment variables* Database query results Filter supports get, post, cookies, server and environment variables as well as defined variables (server support may not work in all sapi, for filter 0.11.0 or php 5.2.0). ....! If you store a session in a database you have several advantages: @ Improving the security because on many hosting packages (shared host) PHP uses the same path for storing sessions for all the users, somewhere that is not in your folders. @ You can track who is online etc. @ For application that are running on multiple servers, you can store all the session data in one database. The real beauty of this approach is that you don't have to mod....! function isbn10_to_13($isbnold){ if (strlen($isbnold) != 10){ // Make sure we have a 10 digit string to startreturn 'Invalid ISBN-10, must be 10 digits';} // prefix with 978 and drop old checksum (last digit)$isbn = '978'.substr($isbnold,0,9); for ($i = 0; $i <= 12; $i++){ // For each digit if new isbn$weight = ($i%2 == 0)? 1 : 3; // Alternate between 1's and 3's$check_sum_total = $check_sum_total + ($isbn{$i} * $weight); // multiply each digit by 1 or 3 and add to $checksumtotal} $....!

function isbn10_to_13($isbnold){

if (strlen($isbnold) != 10){ // Make sure we have a 10 digit string to start
return 'Invalid ISBN-10, must be 10 digits';
}

// prefix with 978 and drop old checksum (last digit)
$isbn = '978'.substr($isbnold,0,9);

for ($i = 0; $i <= 12; $i++){ // For each digit if new isbn
$weight = ($i%2 == 0)? 1 : 3; // Alternate between 1's and 3's
$check_sum_total = $check_sum_total + ($isbn{$i} * $weight); // multiply each digit by 1 or 3 and add to $checksumtotal
}

$....!