Saturday, 30 May 2020

PHP 7 Scalar type declarations and return type declarations

PHP 7  Scalar type declarations and return type declarations

What is a Scalar type declarations?
Allowing/Not-Allowing datatype declaration in functions is known as Scalar type declarations.


Question: What are different types of Scalar type declarations?
1) Coercive Mode (default)
2) Strict Mode


What are different type of data-type can be used in Scalar type declarations?
  1. int
  2. float
  3. bool
  4. string
  5. interfaces
  6. array
  7. callable



Question: Give the examples of Scalar type declarations with Coercive Mode (default)
Example 1
$a=1; // integer
$b=2; //integer
function FunctionName1(int $a, int $b){
return $a + $b;
}
echo FunctionName1($a, $b); //3


Example 2
   function sum(int ...$ints) {
      return array_sum($ints);
   }

   print(sum(3, '2', 5.1)); //10


Example 3
function FunctionName3(int $a, int $b){
return $a * $b;
}

echo FunctionName3('hello', 10); //PHP Fatal error: Uncaught TypeError: Argument 1 passed to FunctionName() must be of the type integer, string given.


Example 4
$a='1One'; 
$b=2; //integer
function FunctionName3(int $a, int $b){
return $a + $b;
}
echo FunctionName3($a, $b);//RESULT: PHP Notice: A non well formed numeric value encountered on line 5


Question: Give the examples of Scalar type declarations with STRICT MODE?
Example 1
declare(strict_types=1); 

$a=1; // integer
$b=2; //integer
function phpFunction (int $a, int $b){
return $a + $b;
}

echo phpFunction1($a, $b);//3

Example 2
declare(strict_types=1); 

$a='1'; // String
$b=2; //integer
function phpFunction1 (int $a, int $b){
return $a + $b;
}

echo phpFunction1($a, $b);//Fatal error: Uncaught TypeError: Argument 1 passed to phpFunction1() must be of the type int, string given


Question: Give the examples of Return type declarations with STRICT MODE?
Example 1
$a='10'; //  string
$b=2; // integer
function phpFunctionReturn ($a, $b) : int  {
return $a * $b;
}
echo phpFunctionReturn ($a, $b);


Example 2
declare(strict_types=1); 
$a='10'; //  string
$b=2; // integer
function phpFunctionReturn ($a, $b) : string  {
return $a * $b;
}
echo phpFunctionReturn ($a, $b);//PHP Fatal error:  Uncaught TypeError: Return value of phpFunctionReturn() must be of the type string, integer returned in /home/cg/root/7035270/main.php:6




Friday, 29 May 2020

CSS3 interview questions and answers for experienced

css3 interview questions and answers for experienced



Question: How to write conditional statement in CSS?
<!--[if IE 7]>
<style type="text/css">
div.abc {                 
    background-color:red;
}
</style>
<![endif]-->



Question: How to write styles for all html elements of the same type?
Use tag name to write the CSS.
See Example
h1{font-size:18px;}
h2{font-size:17px;}
h3{font-size:16px;}
h4{font-size:15px;}



Question: What are different vaules of position attributes?
absolute
fixed
inherit
relative
static


Question: How to display a link without underline using CSS?
 a{
    text-decoration:none;
}



Question: How to display a link without underline when mouseover on the link using CSS?
 a:hover{
    text-decoration:none;
}



Question: How to page break after an html element in CSS?
<div style="page-break-after: always;">
Web Technology Experts Notes</div>



Question: What is the default value of "position" attribute in css?
static


Question: How we can specify more than one css class for any HTML element?
<div class="class1 class2">
Web technology experts Notes</div>




Question: Is CSS case sensitive?
No


Question: What is ID selector?
ID selector is an individually identified selector to which a specific style is declared.



Question: How to set wait cursor?
div.click{
    cursor:wait;
}




Question: What is Tweening ?
It process of generating intermediate frames between two images to give the appearance that the first image evolves smoothly into the second image.

Question: What are Child Selectors?
A child selector is used when you want to match an element that is the child of another specific element.
div.abc > ul {font-weight: bold;}



Question: What are different ways to apply styles to a Web page
Inline
Embedded
Linked
Imported



Question: What is contextual selector
Contextual selector addresses specific occurrence of an element.




Question: How to disable text selection highlighting with CSS?
.noselect {
  -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Safari */
     -khtml-user-select: none; /* Konqueror HTML */
       -moz-user-select: none; /* Old versions of Firefox */
        -ms-user-select: none; /* Internet Explorer/Edge */
            user-select: none; /* Non-prefixed version, currently
                                  supported by Chrome, Edge, Opera and Firefox */
}

Add the .noselect to the html tag