Tuesday, 30 October 2012

difee between framework and cms


An application framework is something which we use to build our web application on, I mean we use the framework provided classes, events, methods and create an application.

A CMS is already a developed application with a set of features, however most of them are coded in such a way that users can tweak them around and modify the code to fit their own needs.

Drupal Vs Joomla and other CMS


Drupal Vs Joomla and other CMS

admin's 
picture
Submitted by admin on Thu, 2007-09-27 03:40 A very common question from Beginners is whether I should choose Drupal or Joomla or other CMS?
I had to make this tough decision 2 years back and I thank myself everyday for choosing Drupal over other CMS. I am glad I did not quit when I found some things difficult.
Drupal has a superior architecture and very SEO friendly. It can cater to your needs, it can be used for a simple FAQ site or a very large million visitor site.
Here are some Key pros and cons of the two systems.
Drupal
* Rock solid & high quality platform
* Real multi-site-feature (only one installation for several sites)
* Any Kind of user groups & user permissions, OpenId compliant in Version 6
* Can run membership and community sites, not only CMS etc
* Powerful templating system. Any XHTML or CSS template can be easily converted to Drupal.
* Drupal needs a little time investment to realize all the huge possibilities of Drupal
* Clear, high quality code and API (easy to integrate with other solutions etc)
* Flexibility and no known limitations
* Many high profile sites use Drupal (e.g.: MTV UK, BBC, the Onion, Nasa, Greenpeace UK, New york observer. )
Joomla
* If you are not techy its good to start
* Easy install & setup with your mouse
* Easy learning curve
* Cannot integrate other scripts etc. to your site
* Generally you cannot create high-end sites, without investing huge amount
* No SEO out of the box, URLs are not search engine friendly.
* Server resources utilization is more compared to drupal
* Only one site per installation
* No Single Log-in to several sites
* No User groups & permissions
* More intuitive administration user interface
* Some polished modules for things like calendars, polls, etc.
* Modules cost you money
System Requirements:
  • Drupal can work with MySQL and Postgres while Joomla is known to support only MySQL
  • Drupal can work with Apache or IIS while Joomla is known to support only Apache
  • Joomla support SSL logins and SSL pages. Drupal not known to support it.
Site Management
  • Drupal has free add on for Workflow management. Joomla not known to have one.
  • Drupal has inbuilt Translation manager. Joomla has a Free ad on for the same
  • Drupal has more   granular priviledge managment
Interoperability:
  • Drupal has iCal support [Add on] , Joomla not known to have one.
  • Drupal is XHTML Complaint. Joomla not known to be one.
  • Drupal has excellent versioning and Audit trail which Joomla lacks

mysql interview


  1. How do you start and stop MySQL on Windows? - net start MySQL, net stop MySQL
  2. How do you start MySQL on Linux? - /etc/init.d/mysql start
  3. Explain the difference between mysql and mysqli interfaces in PHP? - mysqli is the object-oriented version of mysql library functions.
  4. What’s the default port for MySQL Server? - 3306
  5. What does tee command do in MySQL? - tee followed by a filename turns on MySQL logging to a specified file. It can be stopped by command notee.
  6. Can you save your connection settings to a conf file? - Yes, and name it ~/.my.conf. You might want to change the permissions on the file to 600, so that it’s not readable by others.
  7. How do you change a password for an existing user via mysqladmin? - mysqladmin -u root -p password "newpassword"
  8. Use mysqldump to create a copy of the database? - mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.sql
  9. Have you ever used MySQL Administrator and MySQL Query Browser? Describe the tasks you accomplished with these tools.
  10. What are some good ideas regarding user security in MySQL? - There is no user without a password. There is no user without a user name. There is no user whose Host column contains % (which here indicates that the user can log in from anywhere in the network or the Internet). There are as few users as possible (in the ideal case only root) who have unrestricted access.
  11. Explain the difference between MyISAM Static and MyISAM Dynamic. - In MyISAM static all the fields have fixed width. The Dynamic MyISAM table would include fields such as TEXT, BLOB, etc. to accommodate the data types with various lengths. MyISAM Static would be easier to restore in case of corruption, since even though you might lose some data, you know exactly where to look for the beginning of the next record.
  12. What does myisamchk do? - It compressed the MyISAM tables, which reduces their disk usage.
  13. Explain advantages of InnoDB over MyISAM? - Row-level locking, transactions, foreign key constraints and crash recovery.
  14. Explain advantages of MyISAM over InnoDB? - Much more conservative approach to disk space management - each MyISAM table is stored in a separate file, which could be compressed then with myisamchk if needed. With InnoDB the tables are stored in tablespace, and not much further optimization is possible. All data except for TEXT and BLOB can occupy 8,000 bytes at most. No full text indexing is available for InnoDB. TRhe COUNT(*)s execute slower than in MyISAM due to tablespace complexity.
  15. What are HEAP tables in MySQL? - HEAP tables are in-memory. They are usually used for high-speed temporary storage. No TEXT or BLOB fields are allowed within HEAP tables. You can only use the comparison operators = and <=>. HEAP tables do not support AUTO_INCREMENT. Indexes must be NOT NULL.
  16. How do you control the max size of a HEAP table? - MySQL config variable max_heap_table_size.
  17. What are CSV tables? - Those are the special tables, data for which is saved into comma-separated values files. They cannot be indexed.
  18. Explain federated tables. - Introduced in MySQL 5.0, federated tables allow access to the tables located on other databases on other servers.
  19. What is SERIAL data type in MySQL? - BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT
  20. What happens when the column is set to AUTO INCREMENT and you reach the maximum value for that table? - It stops incrementing. It does not overflow to 0 to prevent data losses, but further inserts are going to produce an error, since the key has been used already.
  21. Explain the difference between BOOL, TINYINT and BIT. - Prior to MySQL 5.0.3: those are all synonyms. After MySQL 5.0.3: BIT data type can store 8 bytes of data and should be used for binary data.
  22. Explain the difference between FLOAT, DOUBLE and REAL. - FLOATs store floating point numbers with 8 place accuracy and take up 4 bytes. DOUBLEs store floating point numbers with 16 place accuracy and take up 8 bytes. REAL is a synonym of FLOAT for now.
  23. If you specify the data type as DECIMAL (5,2), what’s the range of values that can go in this table? - 999.99 to -99.99. Note that with the negative number the minus sign is considered one of the digits.
  24. What happens if a table has one column defined as TIMESTAMP? - That field gets the current timestamp whenever the row gets altered.
  25. But what if you really want to store the timestamp data, such as the publication date of the article? - Create two columns of type TIMESTAMP and use the second one for your real data.
  26. Explain data type TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP - The column exhibits the same behavior as a single timestamp column in a table with no other timestamp columns.
  27. What does TIMESTAMP ON UPDATE CURRENT_TIMESTAMP data type do? - On initialization places a zero in that column, on future updates puts the current value of the timestamp in.
  28. Explain TIMESTAMP DEFAULT ‘2006:09:02 17:38:44′ ON UPDATE CURRENT_TIMESTAMP. - A default value is used on initialization, a current timestamp is inserted on update of the row.
  29. If I created a column with data type VARCHAR(3), what would I expect to see in MySQL table? - CHAR(3), since MySQL automatically adjusted the data type.

php interview


  1. What does a special set of tags <?= and ?> do in PHP? - The output is displayed directly to the browser.
  2. What’s the difference between include and require? - It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
  3. I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem? - PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems.

  4. Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example? - In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like "{$a},000,000 mln dollars", then you definitely need to use the braces.
  5. How do you define a constant? - Via define() directive, like define ("MYCONSTANT", 100);
  6. How do you pass a variable by value? - Just like in C++, put an ampersand in front of it, like $a = &$b
  7. Will comparison of string "10" and integer 11 work in PHP? - Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.
  8. When are you supposed to use endif to end the conditional statement? - When the original if was followed by : and then the code block without braces.
  9. Explain the ternary conditional operator in PHP? - Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.
  10. How do I find out the number of parameters passed into function? - func_num_args() function returns the number of parameters passed in.
  11. If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b? - 100, it’s a reference to existing variable.
  12. What’s the difference between accessing a class method via -> and via ::? - :: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization.
  13. Are objects passed by value or by reference? - Everything is passed by value.
  14. How do you call a constructor for a parent class? - parent::constructor($value)
  15. 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.
  16. Why doesn’t the following code print the newline properly?    <?php
                $str = ‘Hello, there.nHow are you?nThanks for visiting TechInterviews’;
                print $str;
        ?>
    Because inside the single quotes the n character is not interpreted as newline, just as a sequence of two characters - and n.
  17. Would you initialize your strings with single quotes or double quotes? - Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable substitution.
  18. How come the code <?php print "Contents: $arr[1]"; ?> works, but <?php print "Contents: $arr[1][2]"; ?> doesn’t for two-dimensional array of mine? - Any time you have an array with more than one dimension, complex parsing syntax is required. print "Contents: {$arr[1][2]}" would’ve worked.
  19. What is the difference between characters �23 and x23? - The first one is octal 23, the second is hex 23.
  20. With a heredoc syntax, do I get variable substitution inside the heredoc contents? - Yes.
  21. 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.
  22. For printing out strings, there are echo, print and printf. Explain the differences. - echo is the most primitive of them, and just outputs the contents following the construct to the screen. print is also a construct (so parentheses are optional when calling it), but it returns TRUE on successful output and FALSE if it was unable to print out the string. However, you can pass multiple parameters to echo, like:
     <?php echo 'Welcome ', 'to', ' ', 'TechInterviews!'; ?>
    and it will output the string "Welcome to TechInterviews!" print does not take multiple parameters. It is also generally argued that echo is faster, but usually the speed advantage is negligible, and might not be there for future versions of PHP. printf  is a function, not a construct, and allows such advantages as formatted output, but it’s the slowest way to print out data out of echo, print and printf.
  23. I am writing an application in PHP that outputs a printable version of driving directions. It contains some long sentences, and I am a neat freak, and would like to make sure that no line exceeds 50 characters. How do I accomplish that with PHP? - On large strings that need to be formatted according to some length specifications, use wordwrap() or chunk_split().
  24. What’s the output of the ucwords function in this example?
     $formatted = ucwords("TECHINTERVIEWS IS COLLECTION OF INTERVIEW QUESTIONS");
     print $formatted;
    What will be printed is TECHINTERVIEWS IS COLLECTION OF INTERVIEW QUESTIONS.
    ucwords() makes every first letter of every word capital, but it does not lower-case anything else. To avoid this, and get a properly formatted string, it’s worth using strtolower() first.
  25. What’s the difference between htmlentities() and htmlspecialchars()? - htmlspecialchars only takes care of <, >, single quote ‘, double quote " and ampersand. htmlentities translates all occurrences of character sequences that have different meaning in HTML.
  26. What’s the difference between md5(), crc32() and sha1() crypto on PHP? - The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a 160 bit value. This is important when avoiding collisions.
  27. So if md5() generates the most secure hash, why would you ever use the less secure crc32() and sha1()? - Crypto usage in PHP is simple, but that doesn’t mean it’s free. First off, depending on the data that you’re encrypting, you might have reasons to store a 32-bit value in the database instead of the 160-bit value to save on space. Second, the more secure the crypto is, the longer is the computation time to deliver the hash value. A high volume site might be significantly slowed down, if frequent md5() generation is required.
  28. How do you match the character ^ at the beginning of the string? - ^^


Difference between mysql_connect and mysql_pconnect.
short mysql_pconnect() makes a persistent connection to the database which means a SQL link that do not close when the execution of your script ends.

what is difference between mysql_fetch_array(),mysql_fetch_row() and mysql_fetch_object() please insert with example.
mysql_fetch_array():: fetches a result row as a associated array, numeric array
mysql_fetch_object: Fetaches a result row as object.
mysql_fetch_row::fetches a result row as array


What is difference between require_once(), require(), include(). Becouse above three function usely use to call a file in another file.
Difference between require() and require_once(): include() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page).
So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.
Difference between require() and include() is that require() produces a FATAL ERROR if the file you want to include is not found, while include() only produces a WARNING.
There is also include_once() which is the same as include(), but the difference between them is the same as the difference between require() and require_once().
require() stop the further execution of the program as soon as it encounters and error.
include() continues the execution of the program until the last statement even when it encounters a error in between.

What is the difference between echo and print statement?
Difference1:
echo() can take multiple expressions,Print cannot take multiple expressions.
echo has the slight performance advantage because it doesn't have a return value.
True, echo is a little bit faster.
echo() can take multiple expressions,Print cannot take multiple expressions.
Print return true or false based on success or failure whereas echo just does what its told without letting you know whether or not it worked properly.

How to handle drop down box change event without refreshing page?
We can change the contain of a drop down using AJAX without refresh the page. we can call a AJAX function on the onchange event of drop down.


In case of download in php, How will you make a percentage bar showing current status of total 100%?
Use Following Tips for showing Processing Percentage Bar

1. Use Image for displaying Percentage Bar.

2. Change width of Image depending on Processing completed.

Explain about Functions in PHP?
PHP has a large pool of functions and a huge number of them can be created by extensions. These functions can be defined at runtime by defining them inside the code. These functions have to be defined inside the parenthesis except for a class constructor function where there is no argument. Functions can be called or referenced by specifying their name.

What is the use of obj_start()?
Its intializing the object buffer, so that the whole page will be first parsed (instead of parsing in parts and thrown to browser gradually) and stored in output buffer so that after complete page is executed, it is thrown to the browser once at a time.
How to prevent form hijacking in PHP?
Following things can be done for preventing your PHP Form from Hijacking

1. Make register_globals to off to prevent Form Injection with malicious data.
2. Make Error_reporting to E_ALL so that all variables will be intialized before using them.
3. Make practice of using htmlentities(), strip_tags(), utf8_decode() and addslashes() for filtering malicious data in php
4. Make practice of using mysql_escape_string() in mysql.

How can I maintain the count of how many persons have hit my site?
We can write a code in PHP which will increment the count before executing the HTML code.
and this counter will give us the number of hits.

What are new features that are in added in PHP5?
Following are new features added in PHP5

1. PHP 5 introduces the Standard PHP Library (SPL), which provides a number of ready-made classes and interfaces.
2. Access Modifiers are added in PHP5
3. PHP5 has built-in exception classes that makes it very easy to create your own customized exceptions through inheritance.
4. PHP 5 introduces the mysqli (MySQL Improved) extension with support for the features of MySQL databases versions 4.1 and higher. So use of prepare statements are allowed
5. PHP5 comes with PDO which is a common interface for different database systems is only made possible by the new object model.
6. SQLite is a database engine incorporated in php5 which can be used to develope faster, leaner and more versatile applications.
7. In PHP 5 all Extensible Markup Language (XML) support is provided by the libxml2 XML toolkit.
8. The reflection classes included in PHP 5 provide ways to introspect objects and reverse engineer code.
9. In addition to built-in classes, PHP 5 also offers built-in interfaces. Iterator is the most important, as a number of classes and interfaces are derived from this interface.
10. PHP 5 introduces a number of new "magic" methods. Magic methods begin with a double underscore, and this requires changing any user-defined methods or functions that use this naming convention.
11. The major change to PHP in version 5 relating to OOP is usually summed up by saying that objects are now passed by reference.

How i can get ip address
PHP makes REMOTE_ADDR and REMOTE_HOST available for our use, they live
within the SERVER arrays. So:

REMOTE_ADDR - the IP address of the client

REMOTE_HOST - the host address of the client, if available

How can I maintain the count of how many persons have hit my site?
There is no problem to count the hits of your site it is resposibility of os. simply you add a field called hit in your table and write a program that will be execute when your site will be open.the program simply fetch last value of hit field increament by 1 and add to the table.but start by 0.
what is difference between mysql_connect and mysql_pconnect
Mysql_connect opens up a database connection every time a page is loaded. mysql_pconnect opens up a connection, and keeps it open across multiple requests.

Mysql_pconnect uses less resources, because it does not need to establish a database connection every time a page is loaded.

Where does the PHP session stored, either client side or server side?
It is stored at server side because PHP is server side scripting languages
what would be the differences between PHP and Java?
In PHP each page is a script, executed in its own memory environment. That means PHP is great for dynamic web site, whereas server Java is for server-centric applications, which is a different class of problem.

For a "pure" website, development in PHP is way faster, and performance and scalability is easier to achieve than in Java.

How would you initialize your strings with single quotes or double quotes?
In PHP each page is a script, executed in its own memory environment. That means PHP is great for dynamic web site, whereas server Java is for server-centric applications, which is a different class of problem.

For a "pure" website, development in PHP is way faster, and performance and scalability is easier to achieve than in Java.

What is the difference between Split and Explode
split() can work using regular expressions while explode() cannot.

How we know browser properties
get_browser() attempts to determine the capabilities of the user's browser. This is done by looking up the browser's information in the browscap.ini file.

echo $_SERVER['HTTP_USER_AGENT'] . "<hr /> ";

$browser = get_browser();

foreach ($browser as $name => $value) {
echo "<b>$name</b> $value <br /> ";
}