PHP
CRUD App in PHP
In this blog, you'll discover a step-by-step guide on creating a CRUD app in PHP, complete with MySQL integration. When learning a new programming language, mastering CRUD operations is fundamental. But what exactly does CRUD mean? Create Read Update Delete The first step towards this is to make[...]
Understanding PHP’s Array Manipulation: Exploring References and Unsetting
Understanding PHP's Array Manipulation In PHP, arrays are powerful data structures that allow developers to store and manipulate collections of data efficiently. Understanding how to work with arrays effectively is crucial for building robust and scalable applications. In this article, we'll delve into array manipulation techniques using PHP, focusing on[...]
PHP built-in functions
PHP comes with a vast library of built-in functions that you can use for various purposes, ranging from string manipulation, array handling, file operations, session management, and much more. Here's an overview of some of the categories of built-in functions in PHP, along with examples from each category: Name Description[...]
Mastering Dependency Management with Composer: A Comprehensive Guid
Composer Important Commands Composer is an application-level dependency manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries. Composer Commands: composer clearcache This command clears the Composer cache, which can be useful if you want to remove cached data and[...]
Associative Array Example in PHP
<?php $data = array( 'name'=>"John Doe", 'age'=>20, "company_name"=> "XYZ" ); echo $data['name']. "\n"; echo $data['age']. "\n"; echo $data['company_name']. "\n"; ?> Output: $ php associative_array.php John Doe 20 XYZ
Class and Object Example in PHP
<?php class Data { public $data; function setData($data){ $this->data = $data; } function getData(){ return $this->data; } } $data = new Data(); $data->setData( array( "name"=>"John Doe", "age"=>20, "company_name"=> "XYZ" ) ); echo json_encode($data->getData()). "\n"; $dataE1 = new Data(); $dataE1->setData( array( "name"=>"John Doe 1", "age"=>21, "company_name"=> "ABC" ) ); echo json_encode($dataE1->getData()).[...]
PHP: Sum of two number
In PHP, you can add two numbers by using the addition operator +. For example: $num1 = 10; $num2 = 20; $sum = $num1 + $num2; echo $sum; // Outputs 30
PHP How to get first and last name from full name?
<?php $c_name = explode(' ', "Gaurav R Joshi"); echo $firstName = $c_name[0] ?? ''; echo $lastName = end($c_name);
How to create CSV file in PHP?
Create CSV file: PHP fputcsv function help us for creating CSV file. It returns the length of the written string or false on failure. Example: <?php $list = array ( array('ID', 'Name', 'Email', 'Roll Number'), array('1', 'Amit', '789'), array('2', 'Gaurav', '790') ); $fp = fopen('file.csv', 'w'); foreach ($list as $fields)[...]
PHP: serialize() Function
Convert a storable representation of a value. The serialize() function converts a storable representation of a value. To serialize data means to convert a value to a sequence of bits, so that it can be stored in a file, a memory buffer, or transmitted across a network. <?php $data = serialize(array("Red", "Green", "Blue"));[...]