Monthly archive for November 2009

What is parse errors in php ? what is cause of parse errors .

November 29, 2009 | Filed Under PHP | Leave a Comment

Parse errors are those errors  which are found by PHP parsing engine due to following mistakes

  • The missing semicolon

<?php
$var= “a parse error example” // here semicolon is missing
echo $var;
?>

  • Variable use with out $ sing

<?php
var= “a parse error example” ;  // here $ is missing
echo $var;
?>

  • Does not Open/Close symbols

<?php
var= “a parse error example” ;
echo $var;

// here ? is missing.

4)Unescaped quotes
5)Unterminated strings

Article written by urooj

Session Methods in php?

November 29, 2009 | Filed Under PHP | Leave a Comment

session_save_path — Get / set the current session save path

session_is_registered — Find out global variable is register in session

session_unset — empty all session variables

session_cache_expire — get current cache expire

session_cache_limiter — Get and/or set the current cache limiter

session_commit — Alias of session_write_close()

session_decode — Decodes session data from a string

session_destroy — Destroys all data registered to a session

session_write_close — Write session data and end session

session_encode — Encodes the current session data as a string

session_get_cookie_params — Get the session cookie parameters

session_id — Get and/or set the current session id

session_module_name — Get and/or set the current session module

session_name — Get and/or set the current session name

session_regenerate_id — Update the current session id with a newly generated one

session_register — Register one or more global variables with the current session

session_set_cookie_params — Set the session cookie parameters

session_set_save_handler — Sets user-level session storage functions(Like storing to Databases like MySQl,Oracle etc)

session_start — Start session scope

session_unregister — Unregistered a session variable

Article written by urooj

What is meant by Persistent Database Connections?

November 29, 2009 | Filed Under PHP | Leave a Comment

Persistent connections are links that do not close when the execution of your script ends. When a persistent connection is requested, PHP checks if there’s already an identical persistent connection (that remained open from earlier) – and if it exists, it uses it. If it does not exist, it creates the link. An ‘identical’ connection is a connection that was opened to the same host, with the same username and the same password (where applicable).

Article written by urooj

what are the ways to check image mime types in php?

November 29, 2009 | Filed Under PHP | Leave a Comment

There are a few inbuilt options you can use however, for example getimagesize() can return the mimetype, as does some of the new fileinfo functions. The mime type in getimagesize is stored in ‘mime’, and can be accessed as shown below.

<?php

$parts = getimagesize($filename);
echo $parts['mime'];

?>

or

<?php

$parts = getimagesize($filename);
$allowedMimes = array(’image/jpg’, ‘image/png’, ‘image/gif’);

if(in_array($parts['mime'], $allowedMimes))
echo ‘Valid Mimetype!’;

?>

other way

<?php

$filename = ‘Script.jpg.php’;

$parts = explode(’.', $filename); // common (but wrong) method used
echo $parts[1];

echo strrchr($filename, ‘.’); // correct method

?>

<?php

echo system(’file -ib ‘. $filename);

?>

Article written by urooj

what you should know about cookies before start using in php?

November 29, 2009 | Filed Under PHP | 1 Comment

There are a few things you should be aware of:

A. Since cookies are used to record information about your activities on a particular domain, they can only be read by the domain that created them

B. A single domain cannot set more than twenty cookies, and each cookie is limited to a maximum size of 4 KB

C. A cookie usually possesses six attributes, of which only the first is mandatory. Here they are:
a- name: the name of the cookie
b -value: the value of the cookie
c -expires: the date and time at which the cookie expires
d- path: the top-level directory on the domain from which cookie data can be accessed
e-domain: the domain for which the cookie is valid
f- secure: a Boolean flag indicating whether the cookie should be transmitted only over a secure HTTP connection

It’s important to remember that, since cookies are stored on the user’s hard drive, you as the developer have very little control over them. If a user decides to turn off cookie support in his or her browser, your cookies will simply not be saved. Therefore, avoid writing code that depends heavily on cookies; and have a backup plan ready in case cookie data cannot be retrieved from the client.

Two types of cookies

1)– temporary and
2) –persistent cookies

Article written by urooj

© PHPInterviewQuestion.com 2009 - 2010

eXTReMe Tracker