Technical interview questions for software engineers — languages, databases, web, cloud, DevOps, and fundamentals. Browse all topics.

  • PHP Interview Questions

  • OOP Interview Questions

  • jQuery Interview Questions

  • MySQL Interview Questions

  • JavaScript Interview Questions

  • HR Interview Questions

  • HTML Interview Questions

  • C/C++ Interview Questions

  • Showing posts with label difference. Show all posts
    Showing posts with label difference. Show all posts

    Difference between curl and file_get_contents

    Difference between curl and file_get_contents


    In this tutorial,I will explain difference between curl and file_get_contents.
    PHP offers two main options to get a remote file, curl and file_get_contents. There are many difference between the two.
    file_get_contents - It is a function to get the contents of a file
    curl - It is a library.curl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading HTTP form based upload, proxies, cookies.
    file_get_contents() for a remote file, it is very slow, and does not handle redirects, caching, cookies.
    Curl is a much faster alternative to file_get_contents.


    Bookmark and Share

    Difference between include and include_once in php

    Difference between include and include_once in php
    All these functions include and include_once are used to include the files in the php page.


    PHP include() Function:
    If the specified file is not available ,the include() function generates a warning,and executes the
    remaining code.

    Example:
    <?php 
    include("test.php"); 
    ?>


    Bookmark and Share

    PHP implode() Function


    PHP implode() Function


    implode : The implode() function returns a string from the elements of an array.


    Syntax
    implode(separator,array)


    Example: implode() 


    <?php
    $arr = array("PHP","implode","explode" ,"string","functions");
    $str = implode(",", $arr);
    echo $str; 
    ?>


    Output: PHP, implode, explode, string, functions.


    Bookmark and Share

    PHP explode() Function


    PHP explode() Function


    explode :- The explode() function split a string into an array.

    Syntax
    explode(separator,string)


    Note: Separator cannot be an empty string

    Example: explode()

    <?php


    $name= "PHP implode explode string functions";
    $arr = (" ", $name);
    print_r($arr);
    ?>


    Output:
    array([0]=>"PHP",[1]=>"implode",[2]=>"explode",[3]=>"string",[4]=>"functions");


    Bookmark and Share

    Difference between in_array() and array_search() in php?

    Difference between in_array() and array_search() in php?
    In this tutorial,we will study difference between in_array and array_search.

    in_array : -Checks if a value exists in an array
    array_search() :-searches an array for a given value and returns the  corresponding key if successful.

    in_array Syntax:
    in_array(search value, array , strict Boolean);
    search value:- will be the value to search in an array
    array: will the array to search
    strict Boolean: is optional.

    Example:

    <?php
    $name = array("Rajesh", "Sharma", "PHP", "Linux");
    if (in_array("Rajesh", $name)) 
    {
        echo "Yes";
    }
    else
    {
    echo "False";
    }
    ?>

    Output: Yes

    array_search() :-searches an array for a given value and returns the  corresponding key if successful.

    Syntax:
    array_search()(search value, array , strict Boolean);
    search value:- will be the value to search in an array
    array: will the array to search
    strict Boolean: is optional.

    Example:

    <?php
    $name = array(0=>"Rajesh", 1=>"Sharma", 2=>"PHP", 3=>"Linux");
    echo $key = array_search("Rajesh", $name);

    ?>
    Output: 0


    Bookmark and Share