- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1046 Articles for PHP
181 Views
If there are two nested loops, the break statement can be used −break 2;Below is a demonstration with the foreach loop −foreach(...) { foreach(...) { if (my_var_1.name == my_var_2) break 2; //it breaks out of the outermost foreach loop } }For PHP version>=5.3, the below lines of code can be used −foreach (...) { foreach (...) { if (my_var_1.name == my_var_2) goto top; } } top:
387 Views
In this article, we will learn about how to upgrade and update PHP 5.x to PHP 7, PHP 7 which was released in 2015 with speed improvements comparable to the older versions of the PHP.PrerequisitesAssuming that we have already installed PHP 5.x on CentOS7, and mod_php module should be enabled by Apache, and we need Sudo privileges or root user.Enabling the PHP 7 RepositoryAs PHP 7.x is not available in the official repositories, so we need to use IUS community Project Repository.Download the IUS repository in the machine with the below command# curl 'https://setup.ius.io/' -o setup-ius.sh curl 'https://setup.ius.io/' -o setup-ius.sh ... Read More
475 Views
PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. Originally created by Rasmus Lerdorf in 1994, the PHP reference implementation is now produced by The PHP Group. The latest version PHP is PHP7 and it provides 2x faster performance and 50% better memory consumption than PHP version 5.6. This article explains “How to install PHP7 on Ubuntu Linux”.Before installing PHP7, you should need to install a PPA called ondrej/php. This allows you to co-install PHP versions 5.6 and 7.0.Configuring a PPA for co-installable PHP 5.6 + 7.0To configure a PPA, use ... Read More
139 Views
Magento is a fastest growing open source eCommerce platform that uses MySQL and Zend PHP databases. Magento is a very flexible eCommerce platform that facilitates powerful marketing, Management of multiple websites, catalogue management, and integration of Google Website Optimizer and over 50 payment gateways. It gives the flexibility for the users to control the content, look and functionality of the ecommerce.Magento was originally developed by Varien Inc., a US private company in California. Today, some of their largest users are Burger King, Nestle, Murad, BevMo, and Coca-Cola. Magento open source CMS platform provides increased control in terms of merchandising to ... Read More
386 Views
$ operatorOperator is used to define variables in php. For example, message. Such variables can contain any type of value like int, string, etc.$$ operator$$ is a special operator that contains the name of another variable and can be used to access the value of that variable.ExampleFollowing the example, shows the usage of '′vs′$' operators. Live Demo PHP Example Outputmessage Welcome to Tutorialspoint
341 Views
'AND' Logical operator'AND' operator is a logical AND operator but has low precedence to = operator.'&&' Logical operator'&&' is also a logical AND operator but has high precedence to = operator.ExampleFollowing the example, shows the difference of 'AND' vs '&&' operators. Live Demo PHP Example Output$result = $x AND $y bool(true) $result = $x && $y bool(false)
250 Views
'|' Bitwise OR operator'|' operator is a bitwise OR operator and is used to set the bit to 1 if any of the corresponding bit is 1.'||' Logical Or operator'||' is a logical Or operator and works on complete operands as whole.ExampleFollowing example, shows usage of '|' vs '||' operators. Live Demo PHP Example Output$x | $y = 3 $x || $y = 1
431 Views
'!==' comparison operator'!==' operator checks the unequality of two objects with a type check. It does not converts the datatype and makes a typed check.For example 1 !== '1' will results true.'==!' comparison operator'==!' operator is combination of two operators and can be written as == (!operands).ExampleFollowing example, shows usage of '!==' vs '==!' operators. Live Demo PHP Example Output$x !== operator $y = bool(true) $x ==! operator $y = bool(true)
411 Views
Ternary operatorTernary operator is used to replace if else statements into one statement.Syntax(condition) ? expression1 : expression2;Equivalent Expressionif(condition) { return expression1; } else { return expression2; }If condition is true, then it returns result of expression1 else it returns result of expression2. void is not allowed in condition or expressions.Null coalescing operatorNull coalescing operator is used to provide not null value in case the variable is null.Syntax(variable) ?? expression;Equivalent Expressionif(isset(variable)) { return variable; } else { return expression; }If variable is null, then it returns result of expression.Example PHP Example Outputnot passed not passed
399 Views
To parse a CSV file in PHP, the code is as follows. Under fopen(), set the path of the .csv file−Example$row_count = 1; if (($infile = fopen("path to .csv file", "r")) !== FALSE) { while (($data_in_csv = fgetcsv($infile, 800, ", ")) !== FALSE) { $data_count = count($data_in_csv); echo " $data_count in line $row_count: "; $row_count++; for ($counter=0; $counter < $data_count; $counter++) { echo $$data_in_csv[$counter] . ""; } } fclose(infile); }Code explanation − The file can be opened in reading ... Read More