Found 1060 Articles for PHP

PHP program to find the perimeter of rectangle

AYUSH MISHRA
Updated on 10-Dec-2024 14:48:23

4K+ Views

Problem Description Given the length and breadth of a rectangle, we need to implement a PHP program to find the perimeter. A rectangle is a closed two-dimensional figure having 4 sides. The opposite sides are equal and parallel. The angle made by the adjacent side is equal to 90 degrees. The perimeter is the sum of all sides; in other words, the perimeter is two times the sum of length and breadth. In this tutorial, we are going to learn how we can find the perimeter of a given rectangle in PHP using different approaches. Formula of Perimeter of ... Read More

PHP Program to Check if a Number is an Armstrong Number

AYUSH MISHRA
Updated on 03-Dec-2024 18:37:49

3K+ Views

Armstrong Number Armstrong number is a number in which the sum of its digits raised to the power of the number of digits is equal to the number itself. In this article, we are going to discuss how we can check if a given number is Armstrong number or not. Examples Let's understand Armstrong's Number with the help of some input-output examples. Input 9474 Output Yes Explanation This is a four digit-number. The digit in this number are 9, 4, 7 and 4. 9474 = 94 + 44 + 74 + 44= 6561 + 256 + 2401 + 256= ... Read More

How to get selected option value in PHP

NIKI
Updated on 22-Nov-2024 14:20:12

298 Views

In this article, we will see how to get selected option values in PHP, with necessary examples. What is "option value" in PHP? Drop-down menus are created by using the and . PHP allows users to select one or more options from a list. Syntax Below is the syntax of the Option Value in PHP − Text Label-1 Text Label-2 . . . The characteristics related with the tag are − Multiple: This is used to choose multiple choices from a list. ... Read More

How do you parse and process HTML/XML in PHP?

Pankaj Kumar Bind
Updated on 11-Nov-2024 11:23:10

1K+ Views

This article explains how to handle XML documents in PHP. XML (eXtensible Markup Language) is defined as a textual markup language designed for both people and computers. It is a format used for storing and moving data between applications. PHP simplexml_load_string() function provided by PHP allows us to parse XML strings with ease and this function will convert XML string into an object for us which can be examined in order to understand XML data. Usong PHP simplexml_load_string() Method PHP simplexml_load_string() function accepts an XML string and returns a SimpleXMLElement object, the object has properties and methods that will ... Read More

How to Add Elements to the End of an Array in PHP

AYUSH MISHRA
Updated on 01-Nov-2024 13:15:36

5K+ Views

Arrays are linear data structures used to handle data in programming. Sometimes while dealing with arrays we need to add new elements to an existing array.In this article, we will discuss several methods to add elements to the end of an array in PHP, complete with code examples, outputs, and an analysis of the time and space complexity of each approach. Following are different approaches to adding elements to an array − Using square brackets [] We add an element to the end of an array in PHP is by using square brackets []. This syntax is only suitable when ... Read More

How can I force PHP to use strings for array keys?

Timpol
Updated on 16-Aug-2024 10:35:03

152 Views

To force PHP to use strings for array keys is quite easy, as in PHP array keys are automatically stored as integers if the array elements are numbers. If they are not numbers then it will cast to strings. Forcing PHP to Use strings for Array Keys Following are the ways to force PHP to use strings for array Keys Using php array() function Using json_encode() function Using php array() Function If you use the array() function and keep the first key in quotes it will take other keys as a string does not matter if you are ... Read More

SQL Query to Find all the Students with Marks Greater than Average Marks

Mohit Jain
Updated on 18-Aug-2024 20:39:14

1K+ Views

Given task is to find all the students with marks greater than average marks using SQL. i.e. if the marks of students in a class are 65, 75, 89, 92, and, 60 then the average would be 76.2 and, the query should return records with the marks 89 and 92. Let's start step by step. Creating a Table First of all, we need to create a table called Students using the CREATE statement. This table has three columns Student_Id, Subject, and Marks. This table stores three types of subjects, and marks range from 0 to 100 − CREATE TABLE ... Read More

How to use PHP in HTML?

Harsh Laghave
Updated on 29-Jul-2024 10:52:09

311 Views

To use PHP in HTML, you must enclose the PHP code with PHP start tag . In this article from the example we will learn to use and become comfortable with PHP in HTML. PHP (Hypertext Preprocessor) is a popular server-side scripting language used for web development. It allows you to embed dynamic content into your HTML. Approach to use PHP in HTML To effectively use PHP in HTML, you need to enclose PHP code within tags. Remember, PHP files must have a .php extension since PHP code is processed on the server before the page is ... Read More

Performing DataBase Operations in XAMPP

sudhir sharma
Updated on 22-Jan-2024 17:04:55

655 Views

Introduction Navigating through database operations in XAMPP can be challenging, particularly for beginners. Realizing this complexity, over 15 million active monthly users have turned to XAMPP for its ease of use and flexibility. This article offers a step-by-step guide on performing basic database operations in XAMPP, from data insertion to deletion. Let's take the first stride towards mastering your XAMPP database management skills together! Basic DataBase Operations in XAMPP Basic DataBase Operations in XAMPP include performing CRUD operations such as select, insert, update, and delete statements on a MySQL database using PHP. SELECT Statement The SELECT statement is a ... Read More

Setting Up Nginx with MariaDB and PHP/PHP-FPM on Fedora 24 Server and Workstation

Ayush Singh
Updated on 03-Aug-2023 14:54:08

450 Views

Hosting websites and online applications requires setting up a web server infrastructure. In this article, we'll try to understand the setting up of Nginx on Fedora 24 Server and Workstation using MariaDB and PHP/PHP-FPM. This combination creates a strong stack for managing databases and presenting dynamic content. The main concepts covered here can be applied to subsequent versions of Fedora or other Linux distributions, even if Fedora 24 is an older edition. Main Characteristics of Fedora 24 Server Fedora 24 Server was created using the Linux kernel, which serves as the foundation of the operating system. The Linux kernel offers ... Read More

Advertisements