21⟩ Tell me what does a special set of tags <?=$variable ?> do in PHP?
It will output the content of variable into document.
“Jnr PHP/Codeigniter Developer Frequently Asked Questions in various Jnr PHP/Codeigniter Developer job interviews by interviewer. The set of questions are here to ensures that you offer a perfect answer posed to you. So get preparation for your new job interview”
It will output the content of variable into document.
The count() function is used to return the number of elements in an array.
Understanding of arrays and array related helper functions is important for any PHP developer.
PSRs are PHP Standards Recommendations that aim at standardising common aspects of PHP Development.
An example of a PSR is PSR-2, which is a coding style guide.
☛ Private – Visible only in its own class
☛ Public – Visible to any other code accessing the class
☛ Protected – Visible only to classes parent(s) and classes that extend the current class
This is important for any PHP developer to know because it shows an understanding that building applications is more than just being able to write code. One must also have an understanding about privileges and accessibility of that code. There are times protected variables or methods are extremely important, and an understanding of scope is needed to protect the integrity of the data in your application along with provide a clear path through the code.
Those are Notices, Warnings and Fatal errors are the types of errors in PHP. Notices represents non-critical errors. Warnings are more serious errors but they do not result in script termination. Fatal errors are critical errors i.e. calling a non-existent function or class. These errors cause the immediate termination of the script.
In CodeIgniter, the way PHP files served is different rather than accessing it directly from the browser. This process is called routing. Routing in CodeIgniter gives you freedom to customize the default URL pattern to use our own URL pattern according to the requirement. So, whenever there is a request made and matches our URL pattern it will automatically direct to the specified controller and function.
Interface defines the methods and their parameters. Class can then implement the interface (or multiple interfaces) and needs to define such methods. So interface defines outline and class-specific behaviour.
Original form is Personal Home Page. However, according to the PHP manual, it is PHP: Hypertext Preprocessor.
They both include a specific file but on require the process exits with a fatal error if the file can’t be included, while include statement may still pass and jump to the next step in the execution.
No, you cannot extend a Final defined class. A Final class or method declaration prevents child class or method overriding.
Yes, it will, because PHP is not a typed language and it will try to convert variable types before comparison.
It is the basic principle of OOP. You can define base class (may be abstract) Animals and it can then be extended by other classes like Dog, Cat and take part of the behaviour from the parent class.
If hello is true, then the function must print hello, but if the function doesn’t receive hello or hello is false the function must print bye.
<?php
function showMessage($hello=false){
echo ($hello)?'hello':'bye';
}
?>
No. But class can implement multiple interfaces. Multiple inheritance is partially possible using traits.
Using Composer is a tool for dependency management. The candidate can declare the libraries your product relies on and Composer will manage the installation and updating of the libraries. The benefit is a consistent way of managing the libraries depended on so less time is spent managing the libraries.
Explain the starship operator and why it returns the given output
echo 1.5 <=> 2.5; // -1
echo "a" <=> "a"; // 0
echo [1, 2, 3] <=> [1, 2, 4]; // -1
Codeigniter has got a cross-site scripting hack prevention filter. This filter either runs automatically or you can run it as per item basis, to filter all POST and COOKIE data that come across. The XSS filter will target the commonly used methods to trigger JavaScript or other types of code that attempt to hijack cookies or other malicious activity. If it detects any suspicious thing or anything disallowed is encountered, it will convert the data to character entities.
Getters and setters are methods used to declare or obtain the values of variables, usually private ones. They are important because it allows for a central location that is able to handle data prior to declaring it or returning it to the developer. Within a getter or setter one is able to consistently handle data that will eventually be passed into a variable or additional functions. An example of this would be a user’s name. If a setter is not being used and the developer is just declaring the $userName variable by hand, you could end up with results as such: "kevin", "KEVIN", "KeViN", "", etc. With a setter, the developer can not only adjust the value, for example, ucfirst($userName), but can also handle situations where the data is not valid such as the example where "" is passed. The same applies to a getter – when the data is being returned, it can be modifyed the results to include strtoupper($userName) for proper formatting further up the chain.
This is important for any developer who is looking to enter a team-based / application development job to know. Getters and setters are often used when dealing with objects, especially ones that will end up in a database or other storage medium. Because PHP is commonly used to build web applications, developers will run across getters and setters in more advanced environments. They are extremely powerful yet not talked about very much. It is impressive if a developer shows that he/she knows what they are and how to use them early on.
Yes, you can include it multiple times like this.
public, private, protected