Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Sunday 19 October 2014

php navigations



PHP navigations


<?php
if($_SERVER['QUERY_STRING'] == "SoD")
 print "owns you!";
else
 print "don't front!";
?>


Description: Instead of calling files like ( index.php?str=blah ) , you could do ( index.php?SoD ) and it would print out "owns you!". You can add more strings in there, this is just an example.



   $vars = explode(",", urldecode(getenv('QUERY_STRING')));
   $v1 = array_shift($vars);
   $v2 = array_shift($vars);
   $v3 = array_shift($vars);

   switch ($v1) {
       case 'first.1': {
           print("This is v1, first string case 'file.php?first.1'.");
           break;
           }
      case 'first.2': {
      switch ($v2) {
           case 'second': {
               switch($v3) {
                   case 'third': {
                     print("This is v3, the last case 'file.php?first.2,second,third'.");
                     break;
                   }
               }
           }
       }
       }
   }


Description: This basically does what the 1st one does but with more strings and a different seperator rather than '&'. I don't really want to go into too much detail on the thread so if people are confused or need explaining, reply or PM me.

That's it for the navigation as I am not going to do the other due to they're everywhere else and I wanted to be different and show everyone this method.

Friday 6 January 2012

php interview question


Q : 1
Who is the father of PHP ?
Answers :
Rasmus Lerdorf is known as the father of PHP.


Q : 2
What is the difference between $name and $$name?
$name is variable where as $$name is reference variable like $name=sonia and $$name=singh so $sonia value is singh.


Q : 2
What will be the output of the following:
Example 1#
<?php echo 1>2; <?

Example 2#
<?php echo 2>1; <?
Example #1 will produce no output
Example #1 will produce no output: 1


Q : 2
What is the difference between registering a session variable using $_SESSION and session_register('variable_name').

#
$_SESSION
session_register('variable_name').
1
We need to call explicitly session_start() to start a session
It implicitly call session_start()
2
It return type is a string
It returns a boolean vale true or false



Q : 2
What is the difference between copy and move_uploaded_file functions.


Q : 3
How can we submit a form without a submit button?
Java script submit() function is used for submit form without submit button on click call document.formname.submit()


Q : 4
In how many ways we can retrieve the data in the result set of
MySQL using PHP?
Answer : 4
We can do it by 4 Ways
1. mysql_fetch_row. , 2. mysql_fetch_array , 3. mysql_fetch_object
4. mysql_fetch_assoc


Q : 5
What is the difference between mysql_fetch_object and
mysql_fetch_array?
Answers : 5
mysql_fetch_object() is similar tomysql_fetch_array(), with one difference -
an object is returned, instead of an array. Indirectly, that means that
you can only access the data by the field names, and not by their
offsets (numbers are illegal property names).


Q : 6
What are the differences between Get and post methods.
Answers : 6
There are some defference between GET and POST method
1. GET Method have some limit like only 2Kb data able to send for request
But in POST method unlimited data can we send
2. when we use GET method requested data show in url but
Not in POST method so POST method is good for send sensetive request


Q : 7
How can we extract string "pcds.co.in " from a string "http://info@pcds.co.in
using regular expression of PHP?
Answers : 7
preg_match("/^http:\/\/.+@(.+)$/","http://info@pcds.co.in",$matches);
echo $matches[1];


Q : 8
How can we create a database using PHP and MySQL?
Answers : 8
We can create MySQL database with the use of
mysql_create_db("Database Name")


Q : 9
What are the differences between require and include?
Answers : 9
Both include and require used to include a file but when included file not found
Include send Warning where as Require send Fatal Error .


Q : 10
 Can we use include ("xyz.PHP") two times in a PHP page "index.PHP"?
Answers : 10
  Yes we can use include("xyz.php") more than one time in any page. but it create a prob when xyz.php file contain some funtions declaration then error will come for already declared function in this file else not a prob like if you want to show same content two time in page then must incude it two time not a prob


Q : 11
  What are the different tables(Engine) present in MySQL, which one is default?
Answers : 11
 Following tables (Storage Engine) we can create
1. MyISAM(The default storage engine IN MYSQL Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type. An .frm file stores the table format. The data file has an .MYD (MYData) extension. The index file has an .MYI (MYIndex) extension. )
2. InnoDB(InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data.)
3. Merge
4. Heap (MEMORY)(The MEMORY storage engine creates tables with contents that are stored in memory. Formerly, these were known as HEAP tables. MEMORY is the preferred term, although HEAP remains supported for backward compatibility. )
5. BDB (BerkeleyDB)(Sleepycat Software has provided MySQL with the Berkeley DB transactional storage engine. This storage engine typically is called BDB for short. BDB tables may have a greater chance of surviving crashes and are also capable of COMMIT and ROLLBACK operations on transactions)
6. EXAMPLE
7. FEDERATED (It is a storage engine that accesses data in tables of remote databases rather than in local tables. )
8. ARCHIVE (The ARCHIVE storage engine is used for storing large amounts of data without indexes in a very small footprint. )
9. CSV (The CSV storage engine stores data in text files using comma-separated values format.)
10. BLACKHOLE (The BLACKHOLE storage engine acts as a "black hole" that accepts data but throws it away and does not store it. Retrievals always return an empty result)


Q : 12
 What is use of header() function in php ?
Answers : 12
The header() function sends a raw HTTP header to a client.We can use herder()
function for redirection of pages. It is important to notice that header() must
be called before any actual output is seen..


Q : 13
How can I execute a PHP script using command line?
Answers : 13
Just run the PHP CLI (Command Line Interface) program and
provide the PHP script file name as the command line argument.


Q : 14
Suppose your Zend engine supports the mode <? ?> Then how can u
configure your PHP Zend engine to support <?PHP ?> mode ?
Answers : 14
In php.ini file:
set
short_open_tag=on
to make PHP support


Q : 15
Shopping cart online validation i.e. how can we configure Paypal,
etc.?
Answers : 15
Nothing more we have to do only redirect to the payPal url after
submit all information needed by paypal like amount,adresss etc.


Q : 16
What is meant by nl2br()?
Answers : 16
Inserts HTML line breaks (<BR />) before all newlines in a string.


Q : 17
What is htaccess? Why do we use this and Where?
Answers : 17
.htaccess files are configuration files of Apache Server which provide
a way to make configuration changes on a per-directory basis. A file,
containing one or more configuration directives, is placed in a particular
document directory, and the directives apply to that directory, and all
subdirectories thereof.


Q : 18
How we get IP address of client, previous reference page etc ?
Answers : 18
By using $_SERVER['REMOTE_ADDR'],$_SERVER['HTTP_REFERER'] etc.


Q : 19
What are the reasons for selecting lamp (Linux, apache, MySQL,
PHP) instead of combination of other software programs, servers and
operating systems?
Answers : 19
All of those are open source resource. Security of Linux is very
very more than windows. Apache is a better server that IIS both in
functionality and security. MySQL is world most popular open source
database. PHP is more faster that asp or any other scripting language.


Q : 20
How can we encrypt and decrypt a data present in a MySQL table
using MySQL?
Answers : 20
AES_ENCRYPT () and AES_DECRYPT ()

Artificial Intelligence (AI)

  Artificial Intelligence (AI) The Power and Potential of Artificial Intelligence Artificial Intelligence (AI) is revolutionizing the world ...