Found 1046 Articles for PHP

Comparing float value in PHP

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

603 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

561 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

296 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

1K+ 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

2K+ 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

What is the use of ini_set() in PHP?

Alok Prasad
Updated on 29-Jun-2020 12:50:11

5K+ Views

PHP allows the user to modify some of its settings mentioned in php.ini using ini_set(). This function requires two string arguments. The first one is the name of the setting to be modified and the second one is the new value to be assigned to it.Parametersvar nameNot all the available options can be changed using ini_set(). There is a list of all available options in the appendix.new valueThe new value for the option.ExampleGiven the line of code will enable the display_error setting for the script if it’s disabled. We need to put the above statement, at the top of the ... Read More

What is the meaning of a Persistent Cookie in PHP?

Alok Prasad
Updated on 29-Jun-2020 12:04:35

830 Views

A persistent cookie is a cookie that is stored in a cookie file permanently on the browser's computer. As we know cookies are small text files which are as a matter, of course, temporary cookies which stored only in the browser's memory. When the browser is closed, temporary cookies will be erased from the memory.When to use persistent cookies −Temporary cookies can not be used for tracking long-term information.Persistent cookies can be used for tracking long-term information.Temporary cookies are safer because no programs other than the browser can access them.Persistent cookies are less secure because users can open cookie files ... Read More

What is Exception Handling in PHP ?

Alok Prasad
Updated on 29-Jun-2020 12:05:32

276 Views

An exception is a problem that arised during the execution of a program. During the execution of a program when an exception occurs, code following the statement will not be executed, and PHP will attempt to find the first matching catch block. If an exception is not caught, a PHP Fatal Error will be issued with an “Uncaught Exception”.Syntax   try {       print "this is our try block";       throw new Exception();       }catch (Exception $e) {          print "something went wrong, caught yah! n";       }finally {   ... Read More

What is .htaccess in PHP?

Alok Prasad
Updated on 29-Jun-2020 11:58:23

7K+ Views

.htaccess is a configuration file for use on web servers running on the web apache server software. when a .htaccess file is placed in a directory which in turn loaded via the Apache web server, then the .htaccess file detected and executed by the Apache server software. .htaccess files can be utilized to modify the setup of the Apache server software to empower additional functionality and fetures that the apache web server softwatre brings to the table. We can use the .htaccess file for alteration various configuration in apache web server software. Some of them are listed below:ErrorDocumentsCreating custom error pages ... Read More

Advertisements