Documente Academic
Documente Profesional
Documente Cultură
What is the use of Final class and can a final class be an abstract?
The Final keyword is used to make the class uninheritable. So the class or its methods can not be overridden.
1 final class Class1 { 2 // ... 3} 4 5 class FatalClass extends Class1 { 6 // ... 7} 8 9 $out= new FatalClass();
An Abstract class will never be a final class as an abstract class must be extendable.
y
23 } 24 }
Whats the taste of it? Obviously its apple Now eat a fruit
1 $fruit = new Fruit(); 2 $fruit->eat();
Whats the taste of it? It doesnt make any sense. does it? Which means the class fruit should not be Instantiable . This is where the abstract class comes into play
1 abstract class Fruit { 2 private $color; 3 4 abstract public function eat() 5 6 public function setColor($c) { 7 $this->color = $c; 8 } 9}
1. 2. 3. 4. 5.
Data (Node, ETC) Modules Blocks and Menus User Permissions Template
Data Base of the system is collection of Nodes. the data pool Modules These are functional plugins that are either part of the Drupal core (they ship with Drupal) or they are contributed items that have been created by members of the Drupal community.
Blocks and Menus This is the next layer where we find blocks and menus. Blocks often provide the output from a module or can be created to display whatever you want, and then can be placed in various spots in your template (theme) layout. Blocks can be configured to output in various ways, as well as only showing on certain defined pages, or only for certain defined users.
User Permissions Here is the next layer where settings are configured to determine what different kinds of users are allow to work and see.
Template This is mainly the site theme or the skin. This is made up predominantly of XHTML and CSS, with some PHP variables intermixed
Understanding this flow of information is very important if you are facing A Drupal project targeted interview as the interviewer might test your overall knowledge of Drupal CMS by asking this sort of questions.
y
1 // similar to print_r(), but dumps to the view and 2 // is disabled if debug isn't > 0 in config.php 3 pr($anything); 4 5 // returns the correctly internationalized plural or 6 // singular depending on locale. 7 __n($singular, $plural, $count, $return);
If you are working with CakePHP and havent figure it out yet, its worth looking through basics.php in the API docs.
The E_DEPRECATED error level is used to indicate that a function or feature has been deprecated.
E_USER_DEPRECATED
The E_USER_DEPRECATED level is intended for indicating deprecated features in user code, similarly to the E_USER_ERROR and E_USER_WARNING levels.
Out put of the above snippet is? B This is mainly because we have the object instance named as $this is for the class B, though the function is instantiated inside class A. But, If you need the expected output which is A, we can call them statically as follows
01 class A { 02 public static function who() { 03 04 05 06 07 08 } 09 10 class B extends A { 11 12 13 14 } 15 16 B::test(); public static function who() { echo __CLASS__; } echo __CLASS__; } public static function test() { self::who(); }
Out put -> A Main limitation of self:: or __CLASS__ are resolved using the class in which the function belongs, as in where it was defined. By introducing late static binding this limitation has been resolved as follows,
01 class A { 02 public static function who() { 03 04 05 06 07 08 } 09 10 class B extends A { echo __CLASS__; } public static function test() { static::who(); // Here comes Late Static Bindings }
11 12 13 14 } 15
16 B::test();
A. Yes, it is secure. It checks for $isAdmin to be True before executing protected operations B. No, it is not secure because it doesnt make sure $action is valid input C. No, it is not secure because $isAdmin can be hijacked by exploiting register_globals D. Yes, it is secure because it validates the user-data $data E. Both A and B The correct answer is C. This code is, by any means, not secure! In fact, it is the classic security exploit of PHP scripts using the register_globals configuration directive. The problem lies in the $isAdmin variable: although this is clearly a Boolean value, it is only set in the event that the user is an Admin and not set at all if the user is not. Because register_globals is enabled, by simply appending that variable to the end of the URL as a GET parameter, a malicious user could easily impersonate an administrator: http://www.example.com/action.php?action=delete&data=foo&isAdmin=1
y
Why we use cakephp? We can just have our own structure and keep developing projects without making things more complicated. Why cake?
The best answer for this question from the cakephp Cookbook is, We dont have to re-invent the wheel. Every time we sit for a new project, we have a more structural way of developing the project with an already installed development environment and we just have to start our rapid application straight a way with the business logic. Some of the key features the framework provides are, - MVC structure - Code generation - CRUD for database interaction - Application scaffolding - Code generation - Built-in validation - Data sanitation - Flexible casching - Localization
MODEL VIEW CONTROLLER, is a software architecture, currently considered an architectural pattern used in software engineering. This isolates business logic from presentation logic. 1. The Model represents the application data 2. The View renders a presentation of model data 3. The Controller handles and routes requests made by the client
y
Simply you will give the answer as : Testing 345 But the answer is : 245 That is because you can not sum a number with a string. The first part, before the plus mark is a string though there is 1 there. So engine will simply get it as 0 and the latter part as 245. so answer will be 245.
y
You can not concatenate 2 string using +. The answer will be 0 ; so here the answer is A.
y
A. echo chr($val); B. echo asc($val); C. echo substr($alpha, $val, 2); D. echo $alpha{$val}; E. echo $alpha{$val+1} An array can be accessed like this as well. $alpha{$val}
heredoc syntax
heredoc syntax can be used to declare complex strings, What will out put the following code snippet?
1 <?php 2 $who = "questions"; 3 echo <<<TEXT 4 So I said, "php interview $who" 5 TEXT; 6 ?>
Answer So I said, php interview questions In general, the functionality of this heredoc syntax is similar to double quotes.
y y
Taxonomy in Drupal
What is taxonomy in drupal? We can define any number of vocabularies (category types) and terms (categories) e.g. Controversial Content: (vocabulary) violence (term) adult content (term) Genre (Vocabulary) Comedy (term) Romance (term) We can config which content types are compatible with which vocabulary and which nodes are belong to which terms. Some important drupal modules: Views, CCK, Path auto, FCK Editor, User points, Flags, Panels, Image cache
y y
What is cakephp
Cakephp is a framework which is used in rapid development. It provides an extensible architecture for developing, maintaining, and deploying applications using MVC (Model View Controller) and ORM(Object Relational Mapping) architectures. Helps developers, in less code and more flexibility.