If both Apache and IIS are installed on same system, when we type localhost at browser which server will run? Will it shows any error?
In my opinion, it doesn't show any error and IIS will take the priority.
If we give the port number then only apache will run(In case both were installed).
I have 10 elements of Array‚ how can i remove 5 array element‚ with single function?
a = array(’a’‚’b’‚’c’‚’d’‚’f’‚’g’‚’h’‚’i’‚’j’‚’k’);
array_splice($a‚ 0‚ 5);
What is RSS? How to use it in Program?
RSS (Really Simple Syndication) is a format for delivering regularly changing web content. Many news-related sites‚ weblogs and other online publishers syndicate their content as an RSS Feed to whoever wants it.
RSS content can be read using software called an "RSS reader"‚ "feed reader" or an "aggregator". The user subscribes to a feed by entering the feed’s link into the reader or by clicking an RSS icon in a browser that initiates the subscription process. The reader checks the user’s subscribed feeds regularly for new content‚ downloading any updates that it finds.
How can we know the count/number of elements of an array?
count($arr) gives the number of elements of array $arr
How many HTTP headers will send to a web page(client side) from server when you use sessions (session_start()) in php?
There are three HTTP headers included in the response:
1. Expires: Thu‚ 19 Nov 1981 08:52:00 GMT
2. Cache-Control: no-store‚ no-cache‚ must-revalidate‚ post-check=0‚ pre-check=0
3. Pragma: no-cache
How can increase the performance of MySQL select query?
We can use LIMIT to stop MySql for further search in table once we have received our required no. of records� also we can use LEFT JOIN or RIGHT JOIN instead of full join in cases we have related data in two or more tables.
What will this output
1
What is Memcache?
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.
Write a query that support in all databases to find n-th record?
SELECT * FROM `TABLE_NAME` LIMIT (n-1) ‚ 1
Can we create dynamic PDF document using PHP? How?
The PHP Library‚ phplib will let you do this and there are a series of functions that will give you good control over the resultant PDF.
A popular choice with many is the excellent FPDF resource which you can find out more about here: http://www.fpdf.org
Why PHP is called a scripting language?
php is translated line by line by the server before it throw the output to the browser.
Give the syntax of Grant and Revoke commands?
Syntax of Grant Command
grant on to
example:
grant all on employee to root;
Syntax of Revoke Command
revoke on from
ex:
revoke all on employee from root;
There are various FAQs that explain all the functions and how to go from creating your first PDF to writing a sophisticated program to format your material and content exactly how you want.
variable Interchange without a third variable
x=x+y
y=x-y
x=x-y
What do you mean by webserver's document root?
Document Root is the webservers default directory from which webserver serves the web documents according to clients request. When we type website address in address bar of browser. It displays the default document which we have define with webserver configuration and it comes from directory which we have defined as Document Root in web server configuration.
What is MIME?
MIME is Multipurpose Internet Mail Extensions is an internet standard for the format of e-mail. Howewer browsers also uses
MIME standart to transmit files. MIME has a header which is added to a begining of the data. When browser sees such header it
shows the data as it would be a file (for example image)
some mimes:
audio/x-ms-wmp
image/png
aplication/x-shockwave-flash
How many ways can we get the value of current session id?
session_id() with no arguments will give the value of current session id
How do I find out the number of parameters passed into function?
function foo()
{
$numargs = func_num_args();
echo "Number of arguments: $numargs\n";
}
foo(1‚ 2‚ 3); // Prints ’Number of arguments: 3’
where are sessions stored‚ client side or server side?
Sessions are stored in the server. Its normally stored under /var/tmp but you can change the default path under php.ini and set it to any custom one.
What is the regular expression? Where do you use it?
Regular expressions are a powerful tool for examining and modifying text. Regular expressions themselves‚ with a general pattern notation almost like a mini programming language‚ allow you to describe and parse text. They enable you to search for patterns within a string‚ extracting matches flexibly and precisely. However‚ you should note that because regular expressions are more powerful‚ they are also slower than the more basic string functions. You should only use regular expressions if you have a particular need.
What is the difference between md5(), crc32() and sha1() crypto on PHP?
All these functions generate a hash code and the basic difference among them is the length of the generated hash.
1) crc32() - Generates the cyclic redundancy checksum polynomial of 32-bit lengths of the string. This is usually used to validate the integrity of data being transmitted. Generates 10-character hexadecimal number.
2) sha1() - Calculates the sha1 hash of a string using the "US Secure Hash Algorithm 1". Generates 40-character hexadecimal number.
3) md5() - Calculates the MD5 hash of a string using the "RSA Data Security Inc. MD5 Message-Digest Algorithm" and returns that hash. Generates 32-character hexadecimal number.
How can we destroy a cookie?
cookie.expires = Now()-1
Why PHP is faster than ASP.NET?
PHP do not have Compiler like ASP.NET‚ hence no object code is created un like in ASP.NET. As the "Object Code Generation" time is saved‚ hence the parsing become faster.
To find out the current year is leap year or not which date() function we’ve to use.
we have to use the argument ’L’ for the date function and it will return 1 if the given year is leap year else it will return 0
What is error control operator?
@
When prepended to an expression in PHP‚ any error messages that might be generated by that expression will be ignored. To resists an error.
Can we create a web robot using PHP? How?
Yes, we can. Using cURL
How many values can the SET function of MySQL take?
Mysql set can take zero or more values but at the maximum it can take 64 values.
How can we destroy the session‚ how can we unset the variable of a session?
To destroy a session:
To unset a variable of a session:
List out the predefined classes in PHP?
Predefined Classes
1. Standard Defined Classes
These classes are defined in the standard set of functions included in the PHP build.
a. Directory
The class from which dir() is instantiated.
b.stdClass
2.Ming Defined Classes
These classes are defined in the Ming extension� and will only be available when that extension has either been compiled into
PHP or dynamically loaded at runtime.
a.swfshape
b. swffill
c. swfgradient
d. swfbitmap
e. swftext
f. swftextfield
g. swffont
h. swfdisplayitem
i. swfmovie
j. swfbutton
k. swfaction
l. swfmorph
m. swfsprite
3. Oracle 8 Defined Classes
These classes are defined in the Oracle 8 extension� and will only be available when that extension has either been compiled into PHP or dynamically loaded at runtime.
a. OCI-Lob
b. OCI-Collection
4. qtdom Defined Classes
These classes are defined in the qtdom extension� and will only be available when that extension has either been compiled into PHP or dynamically loaded at runtime.
a. QDomDocument
b. QDomNode
what mode to use when creating dirs with mkdir?
chmod=0777
Can we create dynamic Word document using PHP? How?
header("Content-type: application/msword");
header("Content-Disposition: attachment; filename=filename.doc");
header( "Cache-Control: must-revalidate‚ post-check=0‚ pre-check=0" );
header("Pragma: no-cache");
What are the advantages/disadvantages of MySQL and PHP?
Php :
Advantage:
Speed‚ Open Source‚ Multi Platform‚ Easy Syntax
Disadvantage:
Has very weak support for error handling and object orientation‚ does not promote strict variable typing - definitely not for beginners who want to learn good coding practices.
Mysql:
MySql is Open source‚ which can be available any time
MySql has no cost of development purpose.
Good for small application.
It also integrates very well with PHP
Disadvantage;
One disadvantage of MySQL is that it does not support relational integrity constraints.
MySQL has other attributes missing including triggers‚ views and stored procedures
What is the port number for phpmyadmin?
3306
Which function gives us absolute path of a file on the server?
getcwd()gives the absolute path of a file on the server.
What is meant by Exceptional Handling?
PHP 5 has an exception model similar to that of other programming languages. An exception can be thrown, try and caught within PHP. A Try block must include at least one catch block. Multiple catch blocks can be used to catch different classtypes; execution will continue after that last catch block defined in sequence. Exceptions can be thrown within catch blocks.
When an exception is thrown, code following the statement will not be executed and PHP will attempt to find the first matching catch block. If an exception is not caught a PHP Fatal Error will be issued with an Uncaught Exception message, unless there has been a handler defined with set_exception_handler().
Throwing an Exception
getMessage(), "\n";
}
// Continue execution
echo 'Hello World';
?>
Extending Exceptions
A User defined Exception class can be defined by extending the built-in Exception class. The members and properties below, show what is accessible within the child class that derives from the built-in Exception class.
The Built in Exception class
If a class extends the built-in Exception class and re-defines the constructor, it is highly recomended that it also call parent::__construct() to ensure all available data has been properly assigned. The __toString() method can be overriden to provide a custom output when the object is presented as a string.
Extending the Exception class
code}]: {$this->message}\n";
}
public function customFunction() {
echo "A Custom function for this type of exception\n";
}
}
/**
* Create a class to test the exception
*/
class TestException
{
public $var;
const THROW_NONE = 0;
const THROW_CUSTOM = 1;
const THROW_DEFAULT = 2;
function __construct($avalue = self::THROW_NONE) {
switch ($avalue) {
case self::THROW_CUSTOM:
// throw custom exception
throw new MyException('1 is an invalid parameter', 5);
break;
case self::THROW_DEFAULT:
// throw default one.
throw new Exception('2 isnt allowed as a parameter', 6);
break;
default:
// No exception, object will be created.
$this->var = $avalue;
break;
}
}
}
// Example 1
try {
$o = new TestException(TestException::THROW_CUSTOM);
} catch (MyException $e) { // Will be caught
echo "Caught my exception\n", $e;
$e->customFunction();
} catch (Exception $e) { // Skipped
echo "Caught Default Exception\n", $e;
}
// Continue execution
var_dump($o);
echo "\n\n";
// Example 2
try {
$o = new TestException(TestException::THROW_DEFAULT);
} catch (MyException $e) { // Doesn't match this type
echo "Caught my exception\n", $e;
$e->customFunction();
} catch (Exception $e) { // Will be caught
echo "Caught Default Exception\n", $e;
}
// Continue execution
var_dump($o);
echo "\n\n";
// Example 3
try {
$o = new TestException(TestException::THROW_CUSTOM);
} catch (Exception $e) { // Will be caught
echo "Default Exception caught\n", $e;
}
// Continue execution
var_dump($o);
echo "\n\n";
// Example 4
try {
$o = new TestException();
} catch (Exception $e) { // Skipped, no exception
echo "Default Exception caught\n", $e;
}
// Continue execution
var_dump($o);
echo "\n\n";
?>
Saturday, August 29, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment