Found 1046 Articles for PHP

Difference Between PHP and JavaScript

Kiran Kumar Panigrahi
Updated on 28-Jul-2022 12:42:36

7K+ Views

JavaScript and PHP are two of the most widely used and flexible computer languages that are used for building websites.PHP is currently the most widely used scripting language for server-side development, whereas JavaScript is a client-side scripting language. PHP is responsible for handling things on the server side, whereas JavaScript is responsible for handling things on the client side of the browser.Since PHP is derived from the C programming language, it is quite simple to learn for anyone who already possesses a solid foundation in C. Although both are used on websites in order to enhance their functionality, one of ... Read More

PHP Pushing values into an associative array?

AmitDiwan
Updated on 20-Nov-2020 05:38:42

1K+ Views

To push values into an associative array, use the brackets [] []. At first create an associative array −$details= array (    'id' => '101',    'name' => 'John Smith',    'countryName' => 'US' );The PHP code is as follows to insert values −Example Live Demo OutputArray (  [studentDetails] => Array (     [0] => Array (        [id] => 101 [name] => John Smith [countryName] => US       )    ) )

Extract numbers after the last hyphen in PHP?

AmitDiwan
Updated on 20-Nov-2020 05:36:38

679 Views

Let’s say the following is our string including hyphen and numbers as well −"John-45-98-78-7898906756"To extract numbers after – i.e. hyphen, use the concept of explode() with parameters - and $yourVariableName.The PHP code is as follows −Example Live Demo Output7898906756

PHP How to cast variable to array?

AmitDiwan
Updated on 20-Nov-2020 05:35:37

549 Views

To cast variable to array, use the below syntax −$yourNewVariableName=(array)$yourVariableName;The PHP code is as follows −Example Live Demo OutputArray ( [0] => Mike [1] => Sam [2] => David )

PHP How to display array values with text “even” to be displayed for even index values

AmitDiwan
Updated on 20-Nov-2020 05:34:16

107 Views

For this, you can use for loop along with some conditions.The PHP code is as follows −Example Live Demo OutputEven 1 Even 3 EvenAbove, for 0th index, the text “Even” is displayed and the same goes on for 2th and 4th index.

How to display array values with do while or for statement in my PHP?

AmitDiwan
Updated on 20-Nov-2020 05:32:52

201 Views

Following is the syntax to display array valuesdo{    //statement1    //statement2    .    .    .    n } while(yourCondition);The PHP code is as follows −Example Live Demo OutputJohn David Mike Sam Carol

What happens if ++ operator is used with string value in PHP?

AmitDiwan
Updated on 20-Nov-2020 05:31:22

82 Views

If you try to use ++ operator with string value then it increments the last character value with 1 and prints the ASCII value.Following is the PHP code −Example Live Demo OutputThe string modified value is=Joho The string incremented value is=11.5

strlen() php function giving the wrong length of unicode characters ?

AmitDiwan
Updated on 20-Nov-2020 05:30:04

382 Views

To get the correct length, use mb_strlen() for Unicode characters.The PHP code is as follows −Example Live DemoOutputThe string length with mb_strlen=9 The string length with strlen=10

PHP Why does this && not trigger as false?

AmitDiwan
Updated on 20-Nov-2020 05:27:49

46 Views

This is because if you use && both conditions must be true. If any one condition becomes false then the overall condition evaluates to false.The PHP code is as follows −Example Live Demo OutputThe above condition is true

CURL context options in PHP

Syed Javed
Updated on 13-Nov-2020 12:18:12

350 Views

IntroductionCURL context options are available when the CURL extension was compiled using the --with-curlwrappers configure option. Given below is list of CURL wrapper context optionsMethodDescriptionmethodHTTP method supported by the remote server. Defaults to GET.headerAdditional headers to be sent during requestuser_agentValue to send with User-Agent: header.contentAdditional data to be sent after the headers. This option is not used for GET or HEAD requests.proxyURI specifying address of proxy server.max_redirectsThe max number of redirects to follow. Defaults to 20.curl_verify_ssl_hostVerify the host. Defaults to FALSE. available for both http and ftp protocol wrappers.curl_verify_ssl_peerRequire verification of SSL certificate used. Defaults to FALSE. available for both ... Read More

Advertisements