Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

51.

How to create a validation object in FuelPHP?

Answer»

1. Create an object.

2. INSTANTIATE it, $val = Validation::forge('my_validation');

3. Start adding fields to it, $val = Validation::forge('my_validation');

4. ADD username to it, $val->add('username', 'Your username')->add_rule;

5. Add COLUMN for PASSWORD, $val->add('password', 'Your password')

     ->add_rule('required')

     ->add_rule('min_length', 3)

     ->add_rule('max_length', 10);

(The digits are as per the requirements)

6. Add the next field, the gender field- $val->add('gender', 'Your gender')-

     >add_rule('required')

    ->add_rule('match_collection', array('M', 'F'));

If any other validations are to be given, then give them using add_rule() method.

   Or

Forge ( ) method is used for creating a validating objects, such as $val= Validation:: forge( );

52.

What is Scaffolding in FuelPHP?

Answer»

The TERM Scaffolding is a meta-data programming method NEEDED for building database operations. The scaffolding of the concept FuelPHP which makes the work easy and helpful in allowing to get a basic CRUD APPLICATION that too FOLLOWING simple and easy STEPS. It is one of the common FuelPHP Interview Questions.

53.

How to write the select query in FuelPHP Framework?

Answer»

DB::SELECT('name')->from('admin')->EXECUTE();

54.

What is Presenter and how we can create Presenter in FuelPHP Framework?

Answer»

A CLASS containing LOGIC is called as a presenter. It is useful for generating our view. A presenter can consist of database calls or the RELATED retrievals but not perform any data manipulations.

Example

Creating Presenter is FuelPHP-

classPresenter_Index extends Presenter
{
     // BODY
}

55.

How to install the FuelPHP Framework?

Answer»

9. EXPLAIN the RESERVED Routes in FUELPHP Framework? There are four reserved routes-

  • _403_-This ROUTE is followed at the time of uncaught HttpNoAccessException.
  • _root_-It is the default route to be followed due to the unspecified URI.
  • _404_-At the time of HttpNotFoundException, this route is followed.
  • _500_- Uncaught HttpServerErrorException leads to FOLLOWING this route.
56.

What are the default security features provided by FuelPHP frameworks?

Answer»
57.

Lists the minimum requirements for installing the FuelPHP Framework?

Answer»
  • The minimum PHP version is 5.3.3
  • installed and ENABLED Mbstringphp extension
  • Fileinfophp extension installed and enabled
  • PHPUnit version >=3.7 as per the requirement of RUNNING the UNIT tests.
  • Installed and enabled Mcryptphp extension.
58.

What is HMVC in fuelPHP?

Answer»

It is a HIERARCHICAL Model-View-Controller FRAMEWORK used in FuelPHP providing the permission of requesting the internal controllers from the applications. It is a direct extension to the MVC pattern which HELPS in managing all the pre-defined SCALABILITY ISSUES.

59.

What are the template engines supported by FuelPHP Framework?

Answer»
  • Mustache
  • Jade
  • Dwoo
  • Phptal
  • Markdown
  • Smarty
  • Twig
  • Haml

Interesting, RIGHT? Read on to KNOW more FuelPHP INTERVIEW QUESTIONS.

60.

List some advantages and disadvantages of FuelPHP?

Answer»
  • SPARSE documentation along with incomplete sections.
  • Somewhat complex structure to understand especially by PHP or CODEIGNITER developers at the BEGINNERS to intermediate level.
  • Small community and less NUMBER of applications built
  • Hard to learn the conventions of the NAMING space
61.

Name the current Stable version of FuelPHP

Answer»

In the YEAR 2018, the updated version of FuelPHP, 1.8.1 was released. It CONTAINS improved FUNCTIONALITIES, fixes the bugs, and SEVERAL usual improvements.

62.

What is FuelPHP and why it is used?

Answer»

It is a web APPLICATION framework and is an open source platform which WORKS to execute HMVC pattern. The long list of the features of the TECHNOLOGY is the answer to the above question.

The main traits which MAKE FUELPHP framework user-friendly are-

  • Easy configuration
  • Enhanced usability
  • Provides authorized and authenticated framework
  • Increased portability
  • Ease of use in the server
  • Prevents SQL inject
63.

What are Single or Multi-Module Applications in Phalcon?

Answer»

Single module applications have only ONE module. This application does not mandate a namespace. It has a structure as –

single/

app/

controllers/

models/

views/

public/

css/

img/

js/

Multi-module USES the same document root for all the modules. Each directory in APPS has an MVC structure of its own. Module-specific settings are configured USING Module.php present in each module. The structure is like –

multiple/

apps/

frontend/

controllers/

models/

views/

Module.php backend/

controllers/

models/

views/

Module.php public/

css/

img/

js/

64.

How to declare a variable in Phalcon?

Answer»

No need to DECLARE a VARIABLE in PHALCON; the variable is created when its value is ASSIGNED. Example - $name = “user1”;

65.

Explain the differences between .volt and .phtml files?

Answer»
  • .volt files are written in C language and later COMPILED to PHP code. These can be used as a stand-alone component and includes a set of highly INTEGRATED elements.
  • .phtml files should be created when php is used as a template engine. The VIEW is the default rendering component and is called to execute a particular action. .phtml cannot be used as a stand-alone component.
66.

Explain the differences between Phalcon and Laravel?

Answer»
S.noPHALCONLARAVEL
1.is a php extension WRITTEN in C, which is injected into the php core at runtimeis a source base on which web developers BUILD their applications
2.offers high performance and FAST executionis slower and can process fewer requests compared to Phalcon
3.uses ODM which is fast and has a simple, understandable syntaxrelies on ORM which SUPPORTS almost all the databases
4.uses the Volt template engineuses Blade template engine
5.requires root access to be installeddoesn’t need root access
6.has fewer forum exchanges and documentation compared to Laravelhas a more significant community and more support documentation
15. List the type of views in Phalcon? There are two types of views in Phalcon –
  • Volt – used when the template engine is written in C and compiled in php, can be used as a stand-alone component.
  • Phtml – used when the template engine is in php itself.
67.

How many database engines supported by Phalcon?

Answer»

There are 3 database ENGINES supported by Phalcon – Mysql, POSTGRESQL, and SQLITE.

68.

How can you pass data from the controller to view in Phalcon?

Answer»

You can use setVar() or setVars() in the CONTROLLER’s showAction() method to PASS SINGLE or multiple variables respectively, DIRECTLY to the view.

  • $this->view->setVar('productId', $productId);
  • $this->view->setVars( ['username' => $user->username, 'PHONE' => $contact->phone,] );

Instead of using the above methods, you can also set the variables as $this->view->username = $user->username;

69.

How to inject services into a Volt Template in Phalcon?

Answer»

There are 2 ways to inject services into Volt -

  • Define the function in the dependency injection CONTAINER. Access the service in the TEMPLATE with its name. Example - <input name="‘counter’" VALUE="‘{{maxproduct.getCounter()" }}>
  • When Volt is USED as a stand-alone component, create a COMPILER as $compiler = new VoltCompiler(); and compile the template by passing different return parameters.
70.

Which template engine is used in Phalcon? Explain

Answer»

Volt is the template engine USED in Phalcon. It is fast and designer-friendly. Volt VIEWS are COMPILED in php and have many helpers that make writing views easier and QUICKER.

71.

What is Lazy Initialization in Phalcon?

Answer»

Lazy INITIALIZATION is a technique where a class is automatically LOADED by the Phalcon class ‘Loader’ during RUNTIME. This greatly improves performance. Auto loader does this in 4 ways i.e. by registering

  • namespaces, $loader->registerNamespaces(…)
  • directories, $loader->registerDirs(…)
  • classes, $loader->registerClasses(…)
  • files $loader->registerFiles(…)

and then registering the auto loader as $loader->register();

72.

How to use session in Phalcon?

Answer»

To initiate new session,

  • $session = new Session();
  • $session-&GT;start();

setting data into session

RETRIEVE session data

  • $this->session->get(“key”);

removing session

  • $this->session->remove(“key”'); //remove particular VARIABLE
  • $this->session->destroy(); //remove the session
73.

Please explain Phalcon Routing?

Answer»

In Phalcon, routing is managed by its Router component. This component allows the USER to define and add custom ROUTES that can be mapped to CONTROLLERS or handlers that RECEIVE the requests from the application. The router parses the incoming URI BASED on the information received.

74.

Please explain dependency injection in Phalcon?

Answer»

Dependency Injection (DI) is a pattern through which appropriate objects or instances of a class are created during run-time rather than compile-time. The class, thus, becomes independent from creating the cases and it is the responsibility of DI to know which class requires what objects and provide the same. In Phalcon, the DI COMPONENT IMPLEMENTS dependency injection and manages the global instances of DIFFERENT classes used in the application.

75.

What is ODM in Phalcon?

Answer»

ODM or OBJECT-Document-Mapping is the mapping for NOSQL databases. Phalcon can MAP documents from NoSQL databases through ODM using a UNIQUE ObjectID for each object to be mapped. Phalcon’s ODM offers CRUD functionality, events, validation, and other services. The advantage of ODM is that it is a persistence mechanism where an application model and data SOURCE have no dependencies on each other.

76.

How to increase the CSRF timeout in Phalcon?

Answer»

In Phalcon, we can INCREASE CSRF (Cross-Site REQUEST Forgery) timeout by INCREASING the token time as tokens maintain the user sessions. Token time is valid until the session is valid. The session time can be increased by setting session.gc_maxlifetime to a HIGHER value in the php.ini file.

77.

What is PHQL in Phalcon?

Answer»

PHQL is a HIGH-level, object-oriented QUERY LANGUAGE similar to SQL. Phalcon provides a parser written in C that translates syntax into RDBMS. This in-memory parser uses the same technology as SQLite, which is thread-safe, prevents SQL INJECTION and consumes very less memory, thus giving high PERFORMANCE.

78.

Explain the features of Phalcon?

Answer»

Following are the unique features of Phalcon –

  • Fastest full stack FRAMEWORK for PHP
  • Low memory and CPU consumption
  • Supports the standard MVC directory structure.
  • Loosely coupled, the USER can USE the full framework or use only the REQUIRED components.
  • Uses Dependency injection pattern for faster location of services
  • First framework to implement ORM (Object-Relational-Mapping)
79.

What is Phalcon and why it is used?

Answer»

Phalcon is a full-stack open source framework written in PHP and C (programming LANGUAGES). It is the first framework that implements object-relational-mapping (ORM) in C. This loosely coupled framework is based on MVC (model-view-controller) architecture. Phalcon runs on PHP 5.4 and is one of the fastest FRAMEWORKS. Phalcon can be used for end to end web applications that

  • Need to be super-fast and handle more HTTP requests per second
  • Consume less resource (hardware) STORAGE as the C extensions are loaded along with PHP during the web-server start process and are pre-compiled.
80.

How to create Controllers's Action in Symfony2?

Answer»

In your CREATED controller you can CREATE your action with the FOLLOWING code.Example

public function indexAction()
{
     RETURN $this->RENDER('user/login.html.twig', [ ]);
}

81.

How to create pages in Symfony2?

Answer»
82.

Symfony support which template engine?

Answer»

Symfony SUPPORTS default TEMPLATE ENGINE is Twig, but ever, you are free to use PLAIN PHP code if you WANT.

83.

How to get the parameters from URL's in symfony2?

Answer»

$REQUEST = $this-&GT;CONTAINER->GET('request');
$parameter1 = $request->QUERY->get('parameter1');

84.

How to get current route name in Symfony?

Answer»

$requestName = $this-&GT;CONTAINER->GET('request');
$currentRoute = $requestName->get('_route');

85.

How to create Controllers in Symfony2?

Answer»

CONTROLLER's file DEFAULT location is src/AppBundle/Controller Now you can CREATE here your controller with below code.

Example

NAMESPACE AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class YourControllerName EXTENDS Controller
{
}

 

86.

Please write the steps to install Symfony2 using composer?

Answer»

COMPOSER create-project symfony/framework-standard-edition ProjectName "2.7.*"

// You Can MENTION here you particular VERSION that you want to install

87.

Explain the innovations in Symfony2?

Answer»
88.

What is Symfony 2 and explain its advantages?

Answer»

Symfony2 is embracing high standards. It is CENTERED around HTTP specification and PHP standards. These standards make Symfony2 interoperable with amazing PHP libraries. USING the Dependency Injection (DI) PATTERN, the framework has a built-in DI Container, which MAKES it FLEXIBLE and easy to customize.

89.

How to check an element is exists in array or not in PHP?

Answer»

With the help of in_array() function we can check any element is EXISTS in ARRAY or not. It's return type is TRUE when element is exists and false when an element is not exists in array.

Syntax

in_array(SEARCH,array,type)

Example

$array = array("Best", "Interview", "Questions");
if (in_array("Interview", $array))
{
echo "Element exists in array";
}
else
{
echo "Element not exists in array";
}

90.

How to check a variable is an array or not in PHP?

Answer»

PHP developers use the is_array() function to determine WHETHER a variable is an array or not. It is AVAILABLE for only PHP 4 and above versions.

Example

is_array (var_name)
$VAR = ['Best', 'Interview', 'Questions'];
if(is_array ($var)) {
     // True
}

91.

How to find the index of an element in an array PHP?

Answer»
92.

What is the difference between mysql and mysqli?

Answer»
MySQLMySQLi
This EXTENSION was added in version 2.0 of PHP and deprecated with PHP 5.5.0.Added in PHP 5.5 and is capable to work on MYSQL 4.1.3 or above.
No support for PREPARED statements.Supports prepared statements.
Offers procedural interface.Offers procedural interface as well as object-oriented interface.
No support for the stored procedure.Supports store procedure.
Lags with security and other special features.Users will receive here better security and advanced debugging.
Only SQL queries handled transactions.It supports API transaction.

Note: PHP’s easy to learn algorithm combined with its data semantics makes it a very high-functioning language. Our LIST of PHP interview questions will help you in understanding the CORE elements of PHP while giving you clarity on the subject.

93.

What is the use of ctype_upper() in PHP?

Answer»

The ctype_upper() function in PHP used to check EVERY and each and every personality of a given string is in uppercase or not. If the string in the top case then it RETURNS TRUE otherwise returns False. 99. What are the difference between self and $this in PHP?

self$this
The “self” COMMAND can be used as a static function.The $this command cannot be used as a static function.
Self:: is used to access class variables and other methodsThe $this-> is used to access class variables and methods within.
It does not need an instantiated object.It does need an instantiated object.
94.

What is Web Workers in HTML5?

Answer»
95.

What are the __construct() and __destruct() methods in a PHP class?

Answer»

Constructor and a Destructor both are special functions which are automatically called when an object is created and destroyed.

Example

class Animal
{
    PUBLIC $NAME = "Hello";    
    public function __construct($name)
    {
        echo "Live HERE";
        $this->name = $name;
    }    
    public function __destruct()
    {
        echo "DESTROY here";
    }
}
$animal = new Animal("Bob");
echo "My Name is : " . $animal->name;

96.

Explain the difference between mysql_fetch_array(), mysql_fetch_object()?

Answer»

1. mysql_fetch_object: It RETURNS the RESULT from the database as objects. In this field can be accessed as $result-&GT;NAME

2. mysql_fetch_array: It returns result as an array. In this field can be accessed as $result->[name]

97.

Please explain the difference between isset() and empty()?

Answer»

1. isset(): It returns TRUE if the variable EXISTS and has a value other than NULL. It means variables assigned a "", 0, "0", or FALSE are set.

2. EMPTY(): It checks to SEE if a variable is empty. It INTERPRETED as: "" (an empty string).

isset($var) && !empty($var)

will be equals to !empty($var)

98.

What is the use of nl2br() in PHP?

Answer»

It is used to inserts HTML LINE BREAKS ( <BR /> or <br /> ) in front of each NEWLINE (\N) in a string.

99.

What is substr() in PHP? and how it is used?

Answer»

It is used to extract a part of the string. It allows THREE parameters or arguments out of which two are mandatory, and one is optional

echo substr("Hello world",6);

It will return first six characters from a given string.

92. What the use of var_dump()?

It is used to DUMP information about one or more VARIABLES. It displays structured data such as the type and value of the given variable.

Example:

$var_name1=12; int(12);

100.

What is str_replace()?

Answer»

It is USED to replaces some CHARACTERS with some other characters in a string.

Suppose, we want to Replace the characters "Umesh" in the string "Umesh Singh" with "SONU"

ECHO str_replace("Umesh","Sonu","Umesh Singh");