Sunday, 17 January 2016

How to load disqus when scroll to the bottom of the page?

How to load disqus when scroll to the bottom of the page?

Question: What is Disqus?
It is comment hosting service for web sites and online communities. It provide Services so that you can add comment system in your website.


Question: is Disqus multilingual?
Yes, It is.


Question: When Disqus was Launched?
October 2007


Question: Can we embed disqus in website?
Yes, you can embed.


Question: Does it provides channel for discussion?
Yes, It provides channel to discuss.


Question: What is offical website of Disqus?
http://disqus.com


Question: Can facebook user post comment using their fb account?
Yes, Facebook, twitter and google user can post comment using their account


Question: How to load disqus when scroll to the bottom of the page?
                        
  /*  CONFIGURATION VARIABLES  - MUST SET */
  var disqus_developer = 0;
  var disqus_shortname = 'aboutcity'; // required: replace example with your forum shortname                            
  var disqus_identifier = '/2015/07/ajax-technical-interview-questions-and-answers-for-experienced.html';
  var disqus_url = 'http://www.web-technology-experts-notes.in/2015/07/ajax-technical-interview-questions-and-answers-for-experienced.html';                    
  /*  CONFIGURATION VARIABLES  - MUST SET */
  
  var disqus_loaded = false;

  function load_disqus(){     
    disqus_loaded = true;
    var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
    dsq.src = "http://"+disqus_shortname+".disqus.com/embed.js";       
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);

  }

/** check now bottom of page **/
  window.onscroll = function(e) {
   if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
    //hit bottom of page
    if (disqus_loaded==false){ load_disqus() };
   }
  };



Saturday, 16 January 2016

Advanced PHP Interview Questions and Answers

Advanced PHP Interview Questions and Answers


Question: What is PEAR in php?
PEAR means PHP Extension and Application Repository.
PEAR is a framework and distribution system for reusable PHP components. PEAR can be installed by bringing an automated wizard.
Following are main purpose of PEAR
A structured opensource library .
Distribution and package maintenance.
The PHP Foundation Classes (PFC)
The PHP Extension Community Library (PECL)


Question: How can we repair a MySQL table?
We can repair the MySQL with following 3 queries. Each have its own feature.
REPAIR TABLE tablename
REPAIR TABLE tablename QUICK
REPAIR TABLE tablename EXTENDED


Question: What Is a Persistent Cookie?
A persistent cookie is a cookie which is stored in a cookie file permanently on the browser.
A persistent cookie can be used for tracking long-term information.
Persistent cookies are less secure.


Question: How to create persistent cookie in php?
Cookies will only persistent for as long as you have set them.
setcookie( "cookieName", 'cookieValue', strtotime( '+1 year' ) ); //set for 1 year


Question: What is meant by urlencode and urldecode?
urlencode() returns the URL encoded version of the given string.
It convert special characters into % signs followed by two hex digits.

urldecode() returns the Decodes any %## encoding in the given string. Plus symbols ('+') are decoded to a space character.



Question: How To Get the Uploaded File Information in PHP Global variables?
We are all data in $_FILES variable and are following
$_FILES[$fieldName]['name'] - The Original file name on the browser system.
$_FILES[$fieldName]['type'] – The file type determined by the browser.
$_FILES[$fieldName]['size'] – The Number of bytes of the file content.
$_FILES[$fieldName]['tmp_name'] – The temporary filename of the file in which the uploaded file was stored on the server.
$_FILES[$fieldName]['error'] – The error code associated with this file upload.


Question: How can I execute a PHP script using command line?
php c:/wamp/www/myfile.php


Question: Are objects passed by value OR by reference?
Everything is passed by value.


Question: How do you call a constructor of a parent class from child class?
parent::constructor();


Question: Can we use include ("abc.php") two or more times?
Yes, we can include mutiple times.


Question: What is the difference between the functions unlink and unset?
unlink() deletes the given file from the file system.
unset() makes a variable undefined from memory


Question: What are the different functions in sorting an array?
Sort()
arsort()
asort()
ksort()
natsort()
natcasesort()
rsort()
usort()
array_multisort()
uksort().

Question: How can we get the browser properties using PHP?
$_SERVER['HTTP_USER_AGENT']


Question: How can I configure PHP to show error at runtime?
error_reporting(E_ALL) 



Question: How do I turn off PHP Notices?
Add following code in top of php script.
error_reporting(0);


Question: What is T_PAAMAYIM_NEKUDOTAYIM?
T_PAAMAYIM_NEKUDOTAYIM the scope resolution operator (double colon)
::


Qustion: What is output of following program?
function doSomething( &$arg )
{
    $return = $arg;
    $arg += 1;
    return $return;
}

$a = 3;
$b = doSomething( $a );

echo $a;
echo '\n';
echo $b;


Question: How to protect your website from SQL injection attack?
use mysql_real_escape_string() function.


Question: How to protect your website from CSRF (Cross-Site Request Forgery) attack?
Add a token on every important request to secure important operations


Question: How to protech your website from XSS (Cross-Site Scripting) attack?
use php function htmlentities()


Question: what is the list of sensible functions?
exec(), passthru(), system(), popen(), eval(), preg_replace() 


Question: What is output of following?
$a = 012;
echo $a / 4;