affiliate_link

Wednesday, May 30, 2012

PHP Q&A

1. How many are PHP super global variables?
(a)  $_REQUEST
(b)  $_POST
(c)  $_GET
(d)  $_COOKIES
(e)  $_SERVER
(f)   $_FILES
(g)  $_ENV

2. How can we get images properties like type, size, width, height?
For image type we can use           exif_imagetype()
Image size use                             getimagesize()
Image width                                 imagesx()
Image Height                               imagesy()

3. Get browser properties using PHP?
echo $_SERVER['HTTP_USER_AGENT'];

4. How many ways we can pass data between two pages using php?
(a) Register data in sessions
(b) Use cookies
(c) Pass value as GET or POST

5. How to make a script support multiple languages?
Set charset = UTF-8

6. What is the difference between Echo and Print in PHP?
Echo and print are more or less the same both outputs to the browser.
Difference is print() only takes one argument and returns true on successful printing
Echo is slightly faster than print

7. How to prevent hacking in PHP?
(a) Set Register_globals to OFF to prevent form injection with malicious data
(b) Set Error Reporting to E_ALL to show all error messages
(c) Validate input using htmlentities(), strip_tags(), utf8_decode() & addslashes()

8. What is the difference between Notify URL and Return URL using Paypal?
Notify URL
Notify URL is used by PayPal IPN for sending transaction information 

Return URL
The url to which user is returned after successful payment


9. What is ob_start()?
ob_start() turns on the output buffering. When buffering is ON any output sent from server will be stored in a buffer until ob_end() is called or script ends.
It eliminate Headers already sent problem


Monday, May 28, 2012

How to set dropdown value using jquery?

If you know the value you can set it like this 
 
$("#myddl").val("somevalue");
 
Setting through index
 
$("#mydropdownlist").attr('selectedIndex', 0);