Monday, 11 April 2016

YII interview questions and answers for fresher

yii interview questions and answers for fresher

Question: What is Yii?
Yii is a PHP framework which is based on MVC (Model View Controller).


Question: Is it opensource?
Yes, It is opensource. Download and use as per your project requirement. Question: What is full form of Yii
Yes it is.


Question: In which language, It is written?
PHP.


Question: What is current stable version of Yii?
Version: 2.0.7 dated February 14, 2016.


Question: What is offical website of Yii Framework?
http://www.yiiframework.com


Question: From where i an download Yii Framework?
http://www.yiiframework.com/download


Question: How to start Yii?
http://www.yiiframework.com/tour


Question: What are main feature of Yii framework?
  1. MVC design pattern
  2. Web Service available for Apps like android
  3. Internationalization and localization translation for multilingual.
  4. Caching for speed up the application
  5. Error handling and logging for tracking
  6. cross-site scripting (XSS), cross-site request forgery (CSRF) protection
  7. PHPUnit and Selenium for testing.
  8. Automatic code generation help us to fast development.



Question: How to set default controller on Yii?
array(
    'name'=>'Yii Framework',
    'defaultController'=>'site',
);



Question: How to get current controller id?
echo Yii::app()->controller->id;



Question: How to get current action id?
echo Yii::app()->action->id;



Question: What is the first function that gets loaded from a controller? ?
index



Question: How can we use ajax in Yii?
use ajax helper


Question: What are two type of models in YII
  1. Form models
  2. active records


Question: What are active records model?
Active Record is a design pattern used to abstract database access in an object-oriented way.
active records model is based on this design pattern.


Question: How to define a form model?
class MyLoginForm extends CFormModel
{
    public $username;
    public $password;
    public $rememberMe=false;
}



Question: How to set validation in Form Model?
class MyLoginForm extends CFormModel
{
    public $username;
    public $password;
    public $rememberMe=false; 
    private $_identity;
 
    public function rules()
    {
        return array(
            array('username, password', 'required'),
            array('rememberMe', 'boolean'),
            array('password', 'authenticate'),
        );
    }
 
    public function authenticate($attribute,$params)
    {
        $this->_identity=new UserIdentity($this->username,$this->password);
        if(!$this->_identity->authenticate())
            $this->addError('password','username or password Incorrect .');
    }
}



Question: What are the core application components available on Yii?
  1. db- database connection.
  2. assetManager - manage the publishing of private asset files
  3. authManager - manage role-based access control
  4. cache- manage caching functionality
  5. clientScript- manage javascript and CSS
  6. coreMessages- provides translated core messages
  7. errorHandler- manage errors handling.
  8. themeManager- Manage themes
  9. urlManager- URL parsing and creation functionality
  10. statePersister- mechanism for persisting global state
  11. session- Session management
  12. securityManager- Security Managment



Friday, 8 April 2016

Apache Interview Questions And Answers for experienced

Apache Interview Questions And Answers for experienced

Question: How to set UTF-8 for data store and fetch?
  1. Specify the utf8mb4 character set on all tables and text columns in database.
  2. While getting data from database, set the utf8 character set, like below
    $dbh = new PDO('mysql:charset=utf8mb4');
  3. Add META tag in HTML, For Example:



Question: What is difference between HTTP_HOST and SERVER_NAME?
The SERVER_NAME is defined in server config.
The HTTP_HOST is obtained from the HTTP request header.
To view SERVER_NAME and HTTP_HOST in server, use below code.
echo 'Server Name: '.$_SERVER['SERVER_NAME']; echo "\n";
echo 'HTTP HOST: '.$_SERVER['HTTP_HOST'];



Question: Difference between the Apache HTTP Server and Apache Tomcat?
Apache is HTTP server application which parse the PHP and return HTML.
Apache Tomcat is servlet container which is used to deploy your Java Servlets and JSPs.


Question: How to enable mod_rewrite for Apache 2.2?
To use rewrite mode, use following
a2enmod rewrite

then please re-start the web server.
service apache2 restart



Question: Give few tips for debugging .htaccess rules?
  1. Use a Fake-user agent.
  2. Do not use 301 until you are done testing.
  3. Remember that 301s are aggressively cached in your browser.
  4. Use a HTTP Capture tool.
  5. Use below for htacess testing: http://htaccess.madewithlove.be/ http://htaccess.mwl.be/



Question: How to give 777 permission to a folder and all contents?
chmod -R 777 .



Question: Why WAMP showing 403 Forbidden message on Windows 7?
Wrong Virtual Host configuration
http://www.web-technology-experts-notes.in/2013/04/set-up-virtual-host.html


Question: How to change port number for apache in WAMP?
  1. Open httpd.conf file, in wamp server. Location in My Computer: E:\wamp\bin\apache\apache2.2.22\conf\httpd.conf
  2. Search "Listen 80" and replace the port number.
    Listen 80 
    to
    Listen 8080
  3. Re-Start your wamp Server



Question: What is thread safe or non thread safe in PHP?
A Thread Safe version should be used if you install PHP as an Apache module [Using WampServer/Xampp Server]. The Non Thread Safe version should be used if you install PHP as a CGI binary.


Question: Which PHP mode? Apache vs CGI vs FastCGI?
There are multiple ways to execute PHP scripts on a web server.
Following are three different way to execute the PHP.
  1. Apache:Using mod_php to execute PHP scripts on a web server. It is the most popular.
  2. CGI: Executing PHP scripts with a CGI application on a Web Server. It is the legacy way of running applications.
  3. FastCGI: FastCGI was in between the PHP Apache Module and the CGI application. It allows scripts to be executed by an interpreter outside of the web server.