Found 1060 Articles for PHP

How to get first day of week in PHP?

AmitDiwan
Updated on 24-Dec-2019 12:20:17

2K+ Views

To get the first day of the week in PHP, the code is as follows −Example Live DemoOutputThis will produce the following output −First day = Monday - 09/12/2019ExampleLet us now see another example − Live DemoOutputThis will produce the following output −Displaying Sunday as first day of a week... First day (next week) = Sunday - 15/12/2019

How to get the first element of an array in PHP?

AmitDiwan
Updated on 24-Dec-2019 12:17:45

299 Views

To get the first element of an array in PHP, the code is as follows −Example Live DemoOutputThis will produce the following output−Array value ... Value 1 = 150ExampleLet us now see another example − Live DemoOutputThis will produce the following output −Value 1 = 150

How to get random value out of an array in PHP?

AmitDiwan
Updated on 24-Dec-2019 12:15:57

392 Views

To get random value out of an array in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output −Array values ... Value 1 = 150 Value 2 = 100 Value 3 = 120 Value 4 = 110 Value 5 = 115 Value 6 = 103 Value 7 = 105 Value 8 = 125 Random value from arary = 110ExampleLet us now see another example − Live DemoOutputThis will produce the following output−Array values ... Value 1 = 150 Value 2 = 100 Value 3 = 120 Value 4 = 110 Value 5 = 115 Value 6 = 103 Value 7 = 105 Value 8 = 125 Random values from array...150 115

Concatenation of two strings in PHP program

AmitDiwan
Updated on 24-Dec-2019 12:13:08

234 Views

To concatenate two strings in PHP, the code is as follows −Example Live DemoOutputThis will produce the following output−1.967 and 1.969 Both the values are equal!ExampleLet us now see another example − Live DemoOutputThis will produce the following output−First Name = Jack Second Name = Sparrow Concatenation = JackSparrow

Comparing float value in PHP

AmitDiwan
Updated on 24-Dec-2019 12:10:38

750 Views

To compare float values in PHP, the code is as follows −Example Live DemoOutputThis will produce the following output−2.5 3.5 Both the values aren\'t equalExampleLet us now see another example − Live DemoOutputThis will produce the following example−1.967 1.969 Both the values are equal!

‘AND’ vs ‘&&’ operators in PHP

AmitDiwan
Updated on 24-Dec-2019 12:08:08

2K+ Views

The difference is the precedence when we compare AND with && operator. The precedence of AND operator is lower than the operator = when the evaluation is performed, therefore even if both the operators do the same work, the result is different.ExampleLet us first see an example of the AND operator− Live DemoOutputThis will produce the following output−Result = TrueExampleLet us now see an example of the && operator− Live DemoOutputThis will produce the following output:Result = TrueExampleLet us now see the difference in a single example − Live DemoOutputThis will produce the following output−true false

Comparing two dates in PHP

AmitDiwan
Updated on 02-Jan-2020 06:09:34

698 Views

To compare two dates in PHP, the code is as follows. Here, we have used the equality operator to compare dates −Example Live DemoOutputThis will produce the following output−Date1 = 2019-10-30 Date2 = 2019-10-30 Both the dates are equal!ExampleLet us now see another example− Live DemoOutputThis will produce the following output−Date1 = 2019-11-08 Date2 = 2018-08-10 DateOne is the latest date!

Difference between Python and PHP.

Mahesh Parahar
Updated on 28-Nov-2019 10:48:34

493 Views

PythonPython is a high level programming language with inbuilt big library and is used to develop standalone programs. It was developed by Guido Van Rossum and its first version was released in the year 1990.PHPPHP stands for Hypertext Preprocessor, it is server side scripting language. It was developed in 1995. It is used to create dynamic web based pages.Following are the important differences between Python and PHP.Sr. No.KeyPythonPHP1Learning CurvePython requires good effort if one learns from scratch. It is similar to C++ and Java.PHP is easy to learn if user knows html and javascript.2FrameworksPopular Python frameworks are Flask, DJango.Popular PHP ... Read More

Differentiate between exception and error in PHP

Alok Prasad
Updated on 29-Jun-2020 12:48:40

2K+ Views

Let's discuss the differences between errors and exceptions.Recovering from Error is not possible. The only solution to errors is to terminate the execution. Whereas we can recover from Exception by using either try-catch blocks or throwing an exception back to the caller.You will not be able to handle the Errors using try-catch blocks. Even if you handle them using try-catch blocks, your application will not recover if they happen. On the other hand, Exceptions can be handled using try-catch blocks and can make program flow normally if they happen.Exceptions are related to the application whereas Errors are related to the ... Read More

Is PHP compiled or interpreted?

Alok Prasad
Updated on 29-Jun-2020 12:49:09

3K+ Views

Basically, PHP is interpreted but PHP is compiled down to an intermediate bytecode that is then interpreted by the runtime Zend engine.PHP compiler is responsible forconvert the code to a bytecode that can be used by the runtime engine.resolve functions, names and classes namescreating a symbol tablePHP Interpreter doesGoes through the bytecode line by line and executes itHandles runtime exception

Advertisements