Questions

  1. Difference between static and dynamic function in php oops

2.What is constant and defined in php

3. Laravel event

4. Laravel store processor

5.

user table -> cv table
company tabel -> company_user table

find the company which user has cv

6. jquery jsone.parse and other

7. jquery crose browser request error

8. function((array)$a,(string)$b){ }

9. function overloading and overwriting

10. static function

11. trait class

Advertisements

telephonic round questions

inheritance : normal inherit or call parent class property to child
encapsulation : Public , Private(only defined class can user), Protected (only child class can use) (access modifier)
polymorphic : simply assigning the value and behavior in sub class which is already defined

friend function : are function which defined in class and allow to access all public/ privet data in class
abstract class : which can not be initiate and creating object is not possible it can only inherited

interface : collection of abstract method

traits : allow multiple inheritance and Traits class over ride the extended class methord

——————————

service provider : is a class where all laravel bootstraped
larvel equivalent : way to interference database like : equivalent meaning creating object of a method and run some save and update etc funtionliy on this
constructor : core set of instrcation which service provide by laravel like mail,query

Basic questions

Laravel database table naming convention :

Laravel’s naming convention for pivot tables is singularized table names in alphabetical order separated by an underscore. So, if one table is features, and the other table is products, the pivot table will be feature_product.

You are free to use any table name you want (such as product_feature), but you will then need to specify the name of the pivot table in the relationship. This is done using the second parameter to the belongsToMany() function.

 

What is cUrl?

client url, curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP).

curl uses libcurl

 

What is SOAP?

Simple Object Access Protocol | platform independent |based on XML

SOAP allows you to build interoperable software and allows others to take advantage of your software over a network. It defines rules for sending and receiving Remote Procedure Calls (RPC) such as the structure of the request and responses.

someone can formulate and parse a SOAP message in their chosen language

SOAP provides a way to communicate between applications running on different operating systems, with different technologies and programming languages.

SOAP use in web service

 

File Handling

$myfile = fopen(“webdictionary.txt”, “r”) or die(“Unable to open file!”);
echo fread($myfile,filesize(“webdictionary.txt”));
fclose($myfile);

r : Open a file for read only.
w : Open a file for write only.
a : Open a file for write only.
a : new file if the file doesn’t
x : Creates a new file for write only
r+ : Open a file for read/write
w+ : Open a file for read/write
a+ : Open a file for read/write
x+ : Creates a new file for read/wright

What is Cookie?

A cookie is a small file with the maximum size of 4KB that the web server stores on the client computer. cookies are part of the HTTP request and response headers

<?php

setcookie(cookie_name, cookie_value, [expiry_time], [cookie_path], [domain], [secure], [httponly]);

?>

expiry_time : time() + 3600 for 1 hour

session_destroy() = entire session

uset($_SESSION[‘name]) = fix session variable deleted.

 

What is mySQL engine

Storage engines are MySQL components that handle the SQL operations for different table types. MySQL uses a pluggable storage engine architecture that enables storage engines to be loaded into and unloaded from a running MySQL server.

InnoDB is a storage engine for the database management system MySQL. MySQL 5.5 and later use it by default

Percona XtraDB is a storage engine for the MariaDB and Percona Server databases, and is intended as a drop-in replacement to InnoDB, which is one of the default engines available on the MySQL database

 

Type off array in php?

In PHP, there are three types of arrays: Indexed arrays – Arrays with numeric index. Associative arrays – Arrays with named keys. Multidimensional arrays – Arrays containing one or more arrays.

 

for 3+ experience

How session data is store on server
session expire time
chache expire time
set session time
what is data base collection, utf8_genral_ci, uf8_md
array sum
delete some key value from array.. last .. 2nd last.. with function without function
adding any string in array..end

 

N’th height sallary if some values are same in table sallary collom
$a=’1′, $b=2
$a+$b
$a.$b
if i remove last i++ from “for” loop, than how many time for loop will run
find april data entry from table if date is added in “Y-m-d h:i:s” formate.. with month function and without month function
what route do in laravel
if you want to redirect admin or user module.. how route will set

 

what is jQuery
right join real life example
any in sql

Setup Laravel 5.x with Admin Panel by Boilerpate

Go to link GitHub – rappasoft/laravel-5-boilerplate: A Laravel 5 Boilerplate Project – http://laravel-boilerplate.com

Download setup an extract folder in your local repository

Open setup folder in CMD

Run Command : update composer

Open “Sublime Text” editer or any other editer, Open file .env.example from root directry “save as” file with name “.env”

open .env file Change:
DB_DATABASE=your_DB_name
DB_USERNAME=root
DB_PASSWORD=

Than in CMD run command : PHP artisan migrate
Output will be :

C:\xampp\htdocs\blog>php artisan migrate
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table
Migrating: 2015_12_28_171741_create_social_logins_table
Migrated: 2015_12_28_171741_create_social_logins_table
Migrating: 2015_12_29_015055_setup_access_tables
Migrated: 2015_12_29_015055_setup_access_tables
Migrating: 2016_07_03_062439_create_history_tables
Migrated: 2016_07_03_062439_create_history_tables
Migrating: 2017_04_04_131153_create_sessions_table
Migrated: 2017_04_04_131153_create_sessions_table

Than run next Command :php artisan db:seed
The output will be like this:
C:\xampp\htdocs\blog>php artisan db:seed
Seeding: AccessTableSeeder
Seeding: UserTableSeeder
Seeding: RoleTableSeeder
Seeding: UserRoleSeeder
Seeding: PermissionTableSeeder
Seeding: PermissionRoleSeeder
Seeding: HistoryTypeTableSeeder

Check your DB, you will find all tables Now your setup ready to work
login to admin panel : admin@admin.com and password : 1234

For more info regarding login go to \database\seeds\Access\UserTableSeeder.php file you can change user name here.

MySQL

Question : When we have booking date (start date to end date) in db booking table and need to search from “from date” to ” to date” by search box for available seats.

booking table :

id name start_date end_date
1 a 23-06-2017 29-06-2017

here we need 4 condition to check to do not get in between those dates

Example : Search date can be those

1. 24-06-2017 to 25-06-2017

2. 22-06-2017 to 30-06-2017

3. 22-06-2017 to 24-06-2017

4. 25-06-2017 to 31-06-2017

Now Laravel Query :

$booking_arr = DB::table(‘booking’)
->whereRaw(“((booking.start_date <= ‘”.$start_date.”‘ AND booking.end_date > ‘”.$start_date.”‘) OR (booking.start_date < ‘”.$end_date.”‘ AND booking.end_date >= ‘”.$end_date.”‘) OR (booking.start_date >= ‘”.$start_date.”‘ AND booking.start_date <= ‘”.$end_date.”‘))”)
->where(‘booking.campsite_id’,$input[‘campsite_id’])
->whereIn(‘category_campsite_id’, $campsites_categories)
->get();

PHP string based question

Question : Find number in a string?

preg_replace(“/[^0-9]/”,””,$string); Return string
filter_var($str, FILTER_SANITIZE_NUMBER_INT);
preg_match_all(‘!\d+!’, $str, $matches); Return an array

strpos() : Find the postion in string
Example : echo strpos(“I love php, I love php too!”,”php”);
Output: 7

strpos() : Finds the position of the first occurrence of a string inside another string (case-sensitive)

stripos() : Finds the position of the first occurrence of a string inside another string (case-insensitive)

strripos() : Finds the position of the last occurrence of a string inside another string (case-insensitive)\

substr : Return “world” from the string
Example : echo substr(“Hello world”,-1);
Output : d

strrev() : Reverse the string

strrev(“Hello World!”) : !dlroW olleH

 

Question: Output of code :

$str1 = 'yabadabadoo';
$str2 = 'yaba';
echo  $haspostion = strpos($str1,$str2)) {     ;

Output : 0

Explanation : it show 1st occurence of “yaba” in string which is on position 0 show output will be 0. To awoid this problem we have to check it with

if(strpos($str1, $str2) !== false){

//….you code is here

}

PHP array related qutions

Question: What are different type of sorting functions in PHP?
sort() – sort arrays in ascending order.

$sarray = 
Array([s] => red [x] => blue [3] => orange )
sort($sarray); print_r($sarray);
OUTPUT : Array ( [0] => blue [1] => orange [2] => red )

asort() – sort associative arrays in ascending order, according to the value.
ksort() – sort associative arrays in ascending order, according to the key.

kshort($sarray); print_r($sarray);
OUTPUT : Array([s] => red [x] => blue [3] => orange )

arsort() – sort associative arrays in descending order, according to the value.
rsort() – sort arrays in descending order.
krsort() – sort associative arrays in descending order, according to the key.
array_multisort() – sort the multi dimension array.
usort()- Sort the array using user defined function.

Question: Explaine array_merge()

$a1=array(“red”,”green”);
$a2=array(“blue”,”yellow”);
print_r(array_merge($a1,$a2));

Output:

Array ( [0] => red [1] => green [2] => blue [3] => yellow )

The array_merge() function merges one or more arrays into one array.

Tip: You can assign one array to the function, or as many as you like.

Note: If two or more array elements have the same key, the last one overrides the others.

Note: If you assign only one array to the array_merge() function, and the keys are integers, the function returns a new array with integer keys starting at 0 and increases by 1 for each value (See Example 2 below).

Tip: The difference between this function and the array_merge_recursive() function is when two or more array elements have the same key. Instead of override the keys, the array_merge_recursive() function makes the value as an array.

Exam:

$array1 = array(“color” => “red”, 2, 4);
$array2 = array(“a”, “b”, “color” => “green”, “shape” => “trapezoid”, 4);
$result = array_merge($array1, $array2);

print_r($result);

Array([color] => green [0] => 2 [1] => 4 [2] => a [3] => b [shape] => trapezoid [4] => 4)

$a = [‘1’=>’red’,’2’=>’blue’,’3’=>’orange’,’4’=>’pinks’];
$b = [‘1’=>’red’,’2’=>’blue’,’3’=>’orange’];

print_r(array_merge($a,$b));
OUTPUT :  

Array
(
    [0] => red
    [1] => blue
    [2] => orange
    [3] => pinks
    [4] => red
    [5] => blue
    [6] => orange
)

$a = [‘red’=>’1′,’blue’=>’2′,’orange’=>’3′,’pinks’=>’4’];
$b = [‘red’=>’red’,’blue’=>’blue’,’orange’=>’orange’];

print_r(array_merge($a,$b));

OUTPUT :

Array
(
    [red] => red
    [blue] => blue
    [orange] => orange
    [pinks] => 4
)

Question : Explaine array_search() ?

array_search(value,array,strict)

The array_search() function search an array for a value and returns the key.

$a=array(“a”=>”yellow”,”b”=>”white”,”c”=>”pink”);
echo array_search(“yellow”,$a);

Output : a

Question : Explaine array_combine() ?

The array_combine() function creates an array by using the elements from one “keys” array and one “values” array. > array_combine(keys,values);

$fname=array(“Peter”,”Ben”,”Joe”);
$age=array(“35″,”37″,”43”);

$c=array_combine($fname,$age);
print_r($c);

Output : array(“Peter”=>”35″,”Ben”=>”37″,”Joe”=>”43”);

If number of element is differ in both array than it will show errror;

$a = [‘a’=>’s’,’b’=>’2′,’c’=>’3′];
$b = [‘red’,’d’=>’blue’,’orange’];

print_r(array_combine($a, $b));

OUTPUT :

Array
(
    [s] => red
    [2] => blue
    [3] => orange
)

Question : Explaine array_slice()

$arr = array(“hello”, “good”, “fine”, “good”, “fine”, “hello”, “bye”);
print_r(array_slice($arr,0,-2));

Array ( [0] => hello [1] => good [2] => fine [3] => good [4] => fine )

Question : Explaine array_uniqe()

$arr = array(“hello”, “good”, “fine”, “good”, “fine”, “hello”, “bye”);
print_r(array_unique($arr));

Array ( [0] => hello [1] => good [2] => fine [6] => bye );

$arr = array(“2”, “2”, “3”, “3”, “4”, “4”, “5”);
print_r(array_unique($arr));

Array ( [0] => 2 [2] => 3 [4] => 4 [6] => 5 )

Question : Explaine array_diff()

it compare VALUES of array and will show only 1st array values.

$a1=array(“a”=>”1″,”b”=>”1″,”c”=>”blue”,”d”=>”yellow”);
$a2=array(“e”=>”1″,”f”=>”1″,”g”=>”1″,”d”=>”yellow”);

$result=array_diff($a1,$a2);
print_r($result);

Array ( [c] => blue )

Delete array value without foreach :

$messages = [312, 401, 1599, 3, …];

if(($key = array_search($del_val, $messages)) !== false) {

unset($messages[$key]);

}

array_walk : Apply a user supplied function to every member of an array

bool array_walk ( array &$array , callable $callback [, mixed $userdata = NULL ] )

jquery quetions

What is the purpose of ‘this’ operator in JavaScript?

JavaScript famous keyword this always refers to the current context.
———————————————

Global Variables − A global variable has global scope which means it is visible everywhere in your JavaScript code.

Local Variables − A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.

Which type of variable among global and local, takes precedence over other if names are same?

A local variable takes precedence over a global variable with the same name.

——————————————————

pop() : built-in method removes the last element from an array and returns that element
————————————————–
length() : built-in method returns the length of the string

———————————————-
reverse() :  built-in method reverses the order of the elements of an array
———————————————–
sort() : built-in method sorts the elements of an array
———————————————–
substr() : built-in method returns the characters in a string beginning at the specified location
————————————————
toLowerCase() : built-in method returns the calling string value converted to lower case
toUpperCase()
————————————————

select multiple elements using jQuery?

$(‘E, F, G’)

—————————————

attributes of an element using jQuery?

The attr()

set attributes of an element using jQuery?

The attr(name, value)

—————————————-

How can you apply a style on an element using jQuery?

The addClass( classes )

————————————

remove an attribute from each of the matched elements using jQuery?

The removeAttr( name )
———————————-
specified class is present on at least one of the set of matched elements using jQuery?

The hasClass( class )

————————————
specified class if it is not present, remove the specified class if it is present using jQuery?

The toggleClass(class)


Question : What is selectors? How many selectors are in jquery?

Check this link : https://www.w3schools.com/jquery/jquery_ref_selectors.asp

checks the current selection against an expression using jQuery?

The is( selector )
————————————

select a subset of the matched elements using jQuery?

The slice(selector)
————————————–

add more elements, matched by the given selector, to the set of matched elements using jQuery?

The add( selector )

———————————————-

The .detach() and .remove() methods are the same, except that .detach() retains all jQuery data associated with the removed elements and .remove() does not. .detach() is therefore useful when removed elements may need to be reinserted into the DOM at a later time

.empty(): This method removes all the child element of the matched element where remove() method removes set of matched elements from DOM.

.remove(): This method takes elements out of the DOM. Use .remove() when you want to remove the element itself, as well as everything inside it. In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed
—————————————

 

append() : jQuery object to insert at the end of each element in the set of matched elements.

<h2>Greetings</h2>
<div class="container">
<div class="inner">
Hello
<p>Test</p>
</div>
<div class="inner">
Goodbye
<p>Test</p>
</div>
</div>
You can also select an element on the page and insert it into another:

Example :    $( ".container" ).append( $( "h2" ) );

Output :

<div class="container">
<div class="inner">Hello</div>
<div class="inner">Goodbye</div>
<h2>Greetings</h2>
</div>