What’s the difference between <SPAN> and <div> tags?
Span is for inline elements. Div is for block elements.
<div>tags are block elements that allow you to position elements contained within block.
tags used for inline styling of text.
<div> tags create line breaks, <span> tags doesn’t.
div elements are placed in a row, in other words automatic break is inserted. Whereas in case of span elements all are coming one after the other without any breaks.
Note: Can change inline element into block level element through CSS and vise-versa.
div{display:inline}
span{display:block}
Explain Data encryption in PHP ?
The PHP crypt() function can be used to encrypt data.
MD5 is a one way HASH
base64_encode is for encoding data.
Echo, print, printf – what is the difference between these?
Print and echo both output what is passed to them. Print acts like a function, so you can use it in complex statements. Printf is used to format the output
how variables are passed to functions by reference and by value?
A variable is passed by value unless the variable is passed with an &, such as functionName(&$variableName)
How can I execute a PHP script using command line?
PHP script using command line can be executed using SAPI
(Server Application programming Interface). Using SAPI
Command Line Interface the PHP code can be passed to execute
directly
Example:
Php –r ‘print_r(get_defined_constanrs());’
php filename
From a shell/cmd prompt, php –v will display whether the SAPI is CLI or CGI
explain YAHOO’s 20 points for web performance optimization ?
1. Flush the buffer early [server]
2. Use GET for AJAX requests [server]
3. Post-load components [content]
4. Preload components [content]
5. Reduce the number of DOM elements [content]
6. Split components across domains [content]
7. Minimize the number of iframes [content]
8. No 404s [content]
9. Reduce cookie size [cookie]
10. Use cookie-free domains for components [cookie]
11. Minimize DOM access [javascript]
12. Develop smart event handlers [javascript]
13. Choose <link> over @import [css]
14. Avoid filters [css]
15. Optimize images [images]
16. Optimize CSS sprites [images]
17. Don’t scale images in HTML [images]
18. Make favicon.ico small and cacheable [images]
19. Keep components under 25K [mobile]
20. Pack components into a multipart document [mobile]
FMI : http://developer.yahoo.com/performance/rules.html
What are all the new changes in PHP6 ?
Here is the list :
- FILE_BINARY and FILE_TEXT constants available for use with filesystem functions.
- register_globals will be gone.
- magic_quotes will also disappear.
- $HTTP_*_VARS has been removed, in favour for $_GET, $_POST, etc.
- ereg() no longer available in core PHP6.
- Initiating objects with the reference operator (& new Object()) will generate E_STRICT error.
- E_STRICT error messages are included in E_ALL errors.
- {} for string offsets no longer available.
- [] un-deprecated for accessing characters in a string.
- ASP-style tags can no longer be used.
- Better Unicode Support.
- var will be an alias of public, and raises E_STRICT warning.
- Support for 64 bit integers.
- With ternary operator, the “true” expression is no longer required – this can be done: $a = $s ?: ‘b’; (Not clear yet exactly how this will work).
- zend.ze1_compatibility_mode removed.
- safe_mode is being removed.
- Freetype1 and GD1 support removed.
- dl() is only enabled when a SAPI layers registers it explicitly.
- Support for dynamic break levels removed.
- XMLReader and XMLWriter will be in the core distribution.
- mime_magic removed from the core.
- Fileinfo moved to the core.
- ext/soap on by default.
- foreach supports multi-dimensional arrays: foreach($a as $b => list($c, $d))
- microtime() will return as float by default.
- opcode cache included in core distribution, but turned off by default.
- flags parameter available for file_get_contents().
- before_needle parameter added to strstr() – allows strstr() to return part of haystack before occurence of the needle.
- namespace, import, and goto become reserved words.
FMI : http://blog.tuvinh.com/one-minute-with-php6/