Category: PHP

Progress Element in HTML5

States of progress bar: A progress bar can be in two states – indeterminate and determinate. 1. Indeterminate Indeterminate state of the progress bar in Chrome 29 on Mac OS 10.8 Based on your combination of browser...

PHP Interview Questions for freshers 05

What is meant by urlencode and urldocode? Urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode(“10.00%”) will...

PHP Interview Questions for freshers 04

How can we encrypt the username and password using php? You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD(“Password”); We can encode data using base64_encode($string) and can decode using base64_decode($string); What are the...

PHP Interview Questions for freshers 03

What is meant by nl2br()? Nl2br Inserts HTML line breaks before all newlines in a string string nl2br (string); For example: echo nl2br(“god bless you”) will output “god bless you” to your browser. What...

PHP Interview Questions for Freshers 02

What is the difference between mysql_fetch_object and mysql_fetch_array? MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array. What is the difference...

PHP Interview Questions for freshers 01

What are the differences between GET and POST methods in form submitting, give the case where we can use get and we can use post methods? On the server side, the main difference between...

Extracting Substrings

Problem You want to extract the substring preceding or following a particular match. Solution Use the preg_split() function to split the original string into an array delimited by the match term, and then extract...

Replacing Patterns in a String

Problem You want to replace all/some occurrences of a pattern or substring within a string with something else. Solution Use a regular expression in combination with PHP’s str_replace() function (for simple patters): <?php //...

Counting Matches in a String

Problem You want to find out how many times a particular pattern occurs in a string. Solution Use PHP’s preg_match_all() function: <?php // define string $html = “I’m <b>tired</b> and so I <b>must</b> go...

Searching Strings

Problem You want to search a string for a particular pattern or substring. Solution Use a regular expression with PHP’s ereg() function: <?php // define string $html = “I’m <b>tired</b> and so I <b>must</b>...

Identifying Duplicate Words in a String

into individual words, and then count the occurrences of each word: <?php // define string $str = “baa baa black sheep”; // trim the whitespace at the ends of the string $str = trim($str);...

How do you create sub domains using PHP?

Wild card domains can be used. Sub domains can be created by first creating a sub directory in the /htdocs folder. E.g. /htdocs/mydomain. Then, the host file needs to be modified to define the...

What is CAPTCHA?

CAPTCHA is a test to determine if the user using the system (usually a web form) is a human. It identifies this by throwing challenges to users. Depending on the responses the identification can...

What is Type juggle in php?

Answer Type Juggling means dealing with a variable type. In PHP a variables type is determined by the context in which it is used. If an integer value is assigned to a variable, it...

PHP Script

How can we increase the execution time of a php script? Answer Default time allowed for the PHP scripts to execute is 30s defined in the php.ini file. The function used is set_time_limit(int seconds)....

the functions for IMAP

IMAP is used for communicate with mail servers. It has a number of functions. Few of them are listed below: Imap_alerts – Returns all the imap errors occurred Imap_body – Reads the message body...

PHP Error Type

What are the different types of errors in PHP? Answer Different types of errors are : E_ERROR: A fatal error that causes script termination E_WARNING: Run-time warning that does not cause script termination E_PARSE:...

PHP message

Explain the difference between $message and $$message? Answer $message is used to store variable data. $$message can be used to store variable of a variable. Data stored in $message is fixed while data stored...

PHP cookies

A cookie is used for identification purposes. It is more commonly used to identify a user in a session. It is a small file the application inserts on the users computer. With PHP one...

PHP Urlencode & Urldecode

What is urlencode and urldecode? Answer Urlencode can be used to encode a string that can be used in a url. It encodes the same way posted data from web page is encoded. It...

PHP Include & Require

What is the difference between include and require? Answer Require() and include() are the same with respect to handling failures. However, require() results in a fatal error and does not allow the processing of...

PHP 4 Features

On May 22, 2000, roughly 18 months after the first official announcement of the new development effort, PHP 4.0 was released. Many considered the release of PHP 4 to be the language’s official debut...

Top PHP Interview questions – 12

1401. I need to delete a tag and all child tags from an XML file using PHP. How do I go about ? 1402. Was Bug #37483 ever resolved? 1403. How can i make...

Top PHP Interview questions – 11

1301. I want to upload CSV through PHP script and want capibility to match the colums of tables and DB bef 1302. can event handling can be done via PHP 1303. how check half-byte,single-byte...

Top PHP Interview questions – 10

1201. How do you display multiple ticked checkboxes from a form in a database?? 1202. How do I insert a MySQL database with greek characters in dreamweaver?Greek characters are shown ??? 1203. How can...

Top PHP Interview questions – 09

1101. File Download appears for .php files. Php.ini in \windows on XP. 1102. How can I pass objects from one php file to another? 1103. How to create a web page that refreshes its...

Top PHP Interview questions – 08

1001. How do I call a c program from php, it has to pass a string with it and have ti return a string? 1002. How do I run a php interface to a...

Top PHP Interview questions – 07

901. download file 902. test, mac 903. hide email address 904. How to submit form direct to email 905. How do I code a button that changes the value of a PHP variable? 906....