PHP Interview Questions - V
What is the use of friend function?
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 as global functions. In either case they can be set to be friends of other classes, by using a friend specifier in the class that is admitting them. Such functions can use all attributes of the class which names them as a friend, as if they were themselves members of that class.A friend declaration is essentially a prototype for a member function, but instead of requiring an implementation with the name of that class attached by the double colon syntax, a global function or member function of another class provides the match.
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 intervals. In Windows, it's called Scheduled Tasks. The name Cron is in fact derived from the same word from which we get the word chronology, which means order of time. The easiest way to use crontab is via the crontab command.
# crontab
This command 'edits' the crontab. Upon employing this command, you will be able to enter the commands that you wish to run.
The syntax of this file is very important – if you get it wrong, your crontab will not function properly. The syntax of the file should be as follows:
minutes hours day_of_month month day_of_week command
All the variables, with the exception of the command itself, are numerical constants. In addition to an asterisk (*), which is a wildcard that allows any value, the ranges permitted for each field are as follows:
Minutes: 0-59
Hours: 0-23
Day_of_month: 1-31
Month: 1-12
Weekday: 0-6
Steps for the
payment gateway processing?
An online payment gateway is the interface between your merchant account and your Web site. The online payment gateway allows you to immediately verify credit card transactions and authorize funds on a customer's credit card directly from your Web site. It then passes the transaction off to your merchant bank for processing, commonly referred to as transaction batching
What
is the difference between Reply-to and Return-path in the headers of a mail
function?
Reply-to: Reply-to is where to delivery the reply of the mail.
Return-path: Return path is when there is a mail delivery failure occurs then where to delivery the failure notification
How many ways
can we get the value of current session id?
session_id() returns the session id for the current session.
How do I find out the number of
parameters passed into function?
func_num_args() function returns the number of
parameters passed in.
What’s the special meaning of
__sleep and __wakeup?
__sleep returns the array of all the variables
than need to be saved, while __wakeup retrieves them.
I want to combine two variables
together:
$var1 = 'Welcome to ';
$var2 = 'TechInterviews.com';
What will work faster?
Code sample 1:
$var 3 = $var1.$var2;
Or code sample 2:
$var3 = "$var1$var2";
Both examples would provide the same result - $var3 equal to "Welcome
to TechInterviews.com". However, Code Sample 1 will work significantly
faster. Try it out with large sets of data (or via concatenating small sets a
million times or so), and you will see that concatenation works significantly
faster than variable substitution.
What
is CAPTCHA?
CAPTCHA stands for Completely Automated Public Turing Test to tell Computers and Humans Apart. To prevent spammers from using bots to automatically fill out forms, CAPTCHA programmers will generate an image containing distorted images of a string of numbers and letters. Computers cannot determine what the numbers and letters are from the image but humans have great pattern recognition abilities and will be able to fairly accurately determine the string of numbers and letters. By entering the numbers and letters from the image in the validation field, the application can be fairly assured that there is a human client using it.
CAPTCHA stands for Completely Automated Public Turing Test to tell Computers and Humans Apart. To prevent spammers from using bots to automatically fill out forms, CAPTCHA programmers will generate an image containing distorted images of a string of numbers and letters. Computers cannot determine what the numbers and letters are from the image but humans have great pattern recognition abilities and will be able to fairly accurately determine the string of numbers and letters. By entering the numbers and letters from the image in the validation field, the application can be fairly assured that there is a human client using it.
If you have to work with dates in the following format: "Tuesday, February 14, 2006 @ 10:39 am", how can you convert them to another format, that is easier to use?
The strtotime function can convert a string to a timestamp. A timestamp can be
converted to date format. So it is best to store the dates as timestamp in the
database, and just output them in the format you like.
So let's say we have
$date = "Tuesday, February 14, 2006 @ 10:39 am";
In order to convert that to a timestamp, we need to get rid of the "@" sign, and we can use the remaining string as a parameter for the strtotime function.
So we have
$date = str_replace("@ ","",$date);
$date = strtotime($date);
now $date is a timestamp
and we can say:
echo date("d M Y",$date
So let's say we have
$date = "Tuesday, February 14, 2006 @ 10:39 am";
In order to convert that to a timestamp, we need to get rid of the "@" sign, and we can use the remaining string as a parameter for the strtotime function.
So we have
$date = str_replace("@ ","",$date);
$date = strtotime($date);
now $date is a timestamp
and we can say:
echo date("d M Y",$date
How i can get ip address?
We can use SERVER var $_SERVER['SERVER_ADDR'] and
getenv("REMOTE_ADDR") functions to get the IP address.
No comments:
Post a Comment