Mix PHP Opps All Notes
Mix PHP Opps All Notes
// chetu
I’ve completed INTERNSHIP of 9 months from CHETU Pvt ltd,NOIDA and I have
hands on experience in PHP, HTML, CSS, MySQL, JavaScript, and AJAX.
I'm also familiar with tools like Git, VS Code, and XAMPP server.
During my intership,project
I’m eager
to continue learning and applying my skills, and I'm excited about the
opportunity to contribute to your team.
**"I have worked experiences a Project Analysis Executive at Savi Info Service
Pvt.Ltd Gurgaon. where I was responsible for analyzing and
managing client projects, ensuring timely delivery, and maintaining high
standards of quality. During my time there, I developed strong
skills in project management, client communication, and process improvement.
I have experience working as a Senior Executive for Medical Billing at R System
Company. In this role, I handled various tasks related
to medical billing, such as processing claims, verifying patient information,
and ensuring accuracy in medical codes and billing submissions.
This position helped me gain expertise in the healthcare industry,
I am passionate about building applications that solve real-world problems, and
I’m excited to start my career in a role where I can grow and contribute."
* सवर-साइड: PHP कोड सवर पर ोसेस होता है और ाइं ट को HTML आउटपु ट भे जता है ।
* डाटाबेस सपोट: यह MySQL, PostgreSQL, और Oracle जै से कई डाटाबेस के साथ काम कर सकता है ।
* िसं टै सरल: इसका िसं टै अ ो ािमंग भाषाओं जैसे C, Java से िमलता-जु लता है , िजससे इसे सीखना और उपयोग करना
आसान है ।
* े टफाम तं : यह Windows, Linux, और macOS पर आसानी से काम करता है ।
PHP का उपयोग छोटे से लेकर बड़े वेब ए केशन जै से ई-कॉमस वेबसाइट् स, कंटट मैनेजमट िस म (CMS) और सोशल
मीिडया े टफाम म िकया जाता है ।"
**************************************************
What is PHP?
* PHP (Hypertext Preprocessor) is a server-side scripting language used
primarily for web development.
* It was created in 1994 by Rasmus Lerdorf and is commonly used to develop
dynamic and interactive websites.
* Web Development: Creating dynamic content like user profiles, forms, etc.
* Database Interaction: Storing and retrieving data using databases like MySQL.
* Form Handling: Collecting user data from forms and processing it.
* Building CMS: Content Management Systems like WordPress are built using PHP.
Why XAMPP?
* All-in-One: XAMPP includes all essentials (Apache, MySQL, and PHP),
making it easy to start.
* User-Friendly: XAMPP has a simple control panel to manage servers.
With XAMPP, you have a local server environment ready for PHP development!
===============================
Summary:
* Global: Defined outside functions, accessible only outside unless global is
used.
* Local: Defined inside a function, accessible only within that function.
* Static: Retains its value across function calls when declared as static.
* Super Global: Special variables accessible from anywhere in the script.
===========================
Summary:
* String: Text data.
* Integer: Whole numbers.
* Float: Decimal numbers.
* Boolean: true or false.
* Array: Collection of multiple values.
* Object: Instance of a class with properties and methods.
* NULL: Variable with no value.
* Resource: Reference to external data sources.
========================
Summary:----
===================================================
=========================================================================
=============================================================
* Use switch when you need to compare a single variable against multiple
values.
* Remember to include break after each case unless you want to allow
fall-through behavior.
* Always consider using default for handling unexpected values.
This structure helps organize your code and makes it cleaner, especially when
handling multiple conditions based on the same variable.
--------------------------------------------------------------------------------
----------------
Summary of PHP Loops:--
* For Loop: Used when the number of iterations is known.
* While Loop: Used when the number of iterations is not known and depends on a
condition.
* Do While Loop: Similar to while, but executes at least once.
* Foreach Loop: Best for iterating over arrays.
When to Use Loops---
Use a for loop when you know the exact number of iterations.
Use a while loop when the condition depends on a dynamic situation.
Use a do while loop when you need to ensure the code runs at least once.
Use a foreach loop when working with arrays for cleaner and easier code.
Loops are fundamental in programming as they allow you to automate repetitive
tasks, making your code more efficient and manageable.
===================================================================
Summary of PHP Arrays and Array Functions
* Arrays: A way to store multiple values in a single variable.
* Types: Indexed, Associative, and Multidimensional arrays.
* Accessing Elements: Use indexes for indexed arrays and keys for associative
arrays.
* Common Functions: count(), array_push(), array_pop(), in_array(), etc.
* Looping: Use for and foreach loops to iterate through arrays easily.
* Arrays are a fundamental part of PHP and are essential for storing and
manipulating data efficiently. Understanding how to use arrays and their
functions will significantly improve your ability to write effective PHP code.
Summary
* Creating Arrays: Use array() or short syntax [].
* Modifying Arrays: Functions like array_push(), array_pop(), and
array_unshift() are helpful.
* Accessing Elements: Use in_array(), array_keys(), and array_values() for
checks and retrieval.
* Sorting and Merging: Use sort(), rsort(), array_merge(), and more for managing
array order and contents.
* Filtering and Mapping: Use array_filter(), array_map(), and similar functions
for processing array elements.
* These functions make PHP arrays very powerful and versatile for various
programming tasks. Understanding and using these functions can significantly
enhance your ability to handle data in PHP.
---------------------------------------------------------------super global in
php----------------------------------
Summary
* Global Access: Superglobals are available anywhere in your script without
needing to declare them.
* Data Handling: They are essential for managing form data, user sessions, file
uploads, and server information.
* Examples: Commonly used superglobals include $GLOBALS, $_SERVER, $_REQUEST,
$_POST, $_GET, $_FILES, $_SESSION, and $_COOKIE.
Understanding superglobals is crucial for working effectively with PHP,
especially when dealing with user input and session management.
================================================================================
=======function=================
Summary
* Reusable Code: Functions help reuse code and organize it.
* Parameters: Send data into functions using parameters; set defaults if
needed.
* Return Values: Functions can return a value for further use.
* Scope: Local variables are used within functions; global can access global
variables.
* Automatic Behavior: Magic functions let you customize how objects react in
certain situations.
* Useful for Customizing Property Access: Functions like __get, __set, and
__call help manage properties and methods dynamically.
* Helpful for Debugging: __toString, __isset, and __unset make it easy to
format objects for output and manage object properties better.
* Magic functions add flexibility and customization options to PHP classes,
making them valuable in more complex applications and frameworks.
1. __construct()
* Purpose: Initializes an object when it’s created.
* Usage: Often used to set up initial values.
* Example:
class Car {
public function __construct() {
echo "Car created!";
}
}
$myCar = new Car(); // Output: Car created!
2. __destruct()
* Purpose: Called when an object is destroyed.
* Usage: Commonly used for cleanup tasks.
* Example:
class Car {
public function __destruct() {
echo "Car destroyed!";
}
}
$myCar = new Car();
unset($myCar); // Output: Car destroyed!
3. __get($property)
* Purpose: Called when accessing a non-existing or private property.
* Usage: Useful for managing inaccessible properties.
* Example:
class Car {
private $properties = [];
4. __set($property, $value)
* Purpose: Called when setting a value to a non-existing or private property.
* Usage: Can be used to manage dynamic properties.
* Example:
5. __isset($property)
* Purpose: Triggered by isset() or empty() on inaccessible properties.
* Usage: Helpful for custom checks on properties.
* Example:
class Car {
public function __isset($name) {
return isset($this->$name);
}
}
6. __unset($property)
* Purpose: Called when unset() is used on inaccessible properties.
* Usage: Manage what happens when a property is unset.
* Example:
7. __call($method, $arguments)
* Purpose: Triggered when calling a non-existing or inaccessible method.
* Usage: Custom handling for undefined methods.
* Example:
$myCar->drive(); // if drive() method is undefined
8. __callStatic($method, $arguments)
* Purpose: Called when invoking an undefined static method.
* Usage: Similar to __call() but for static methods.
* Example:
9. __toString()
10. __invoke()
* Purpose: Triggered when trying to call an object as a function.
* Usage: Use an object like a function.
* Example:
11. __clone()
* Purpose: Called when an object is cloned.
* Usage: Manage any custom behavior when duplicating an object.
* Example:
$cloneCar = clone $myCar;
12. __sleep()
* Purpose: Called when serializing an object.
* Usage: Returns an array of properties to serialize.
* Example:
serialize($myCar);
13. __wakeup()
* Purpose: Called when unserializing an object.
* Usage: Useful for reconnecting to resources.
* Example:
unserialize($data);
15. __debugInfo()
* Purpose: Defines what var_dump() displays for an object.
* Usage: Custom debugging output.
* Example:
var_dump($myCar);
16. __set_state()
* Purpose: Called when using var_export() with a class.
* Usage: Customizes class export information.
* Example:
var_export($myCar);
------------------------------------------------OOPS CONCEPTS IN
PHP:---------------------------
Summary:---
* Class & Object: Building blocks of OOP.
* Encapsulation: Protects data by controlling access.
* Inheritance: Allows code reuse by extending classes.
*Polymorphism: Same method behaves differently for different classes.
* Abstraction: Defines a structure for classes to follow.
* These concepts make PHP code modular, reusable, and easier to manage,
especially in larger projects.
Summary:--
# Single Inheritance: One parent, one child.
# Multilevel Inheritance: Chain of inheritance across multiple classes.
# Hierarchical Inheritance: One parent with multiple child classes.
# Multiple Inheritance: Not directly supported in PHP; use traits instead.
# Inheritance allows code reuse and helps organize related classes, making OOP
code cleaner and more maintainable.
PHP म Inheritance के साथ कुछ खास बात:
1...)Method Overriding: Derived ास अपने parent ास के मेथड् स को ओवरराइड कर सकती है ।
class Animal {
public function makeSound() {
echo "Animal sound!";
}
}
2..) Protected Members: Protected ॉपट ज़ और मेथड् स केवल उसी ास म या उन ासे स म ए े स िकए जा
सकते ह जो उसे इनहे रट करती ह।
class Animal {
protected $name;
3..)Final Keyword: अगर िकसी ास या मे थड को final घोिषत िकया गया है , तो उसे आगे इनहे रट या ओवरराइड
नहीं िकया जा सकता।
class Animal {
final public function makeSound() {
echo "Animal sound!";
}
}
// This will throw an error if you try to override makeSound method in Dog
class.
Summary-------
* Traits are a way to share code between classes without inheritance.
* They’re defined with trait and included in classes with use.
* You can combine, resolve conflicts, and override methods within traits, making
them flexible and powerful for PHP projects.
* This makes traits perfect for situations where you need reusable code across
unrelated classes!
Summary:---
* Namespaces organize code and prevent naming conflicts.
* Defined using the namespace keyword.
* Access classes with a fully qualified name (\Namespace\ClassName) or use use
to alias for easier access.
* This makes namespaces especially useful in large projects and with external
libraries!
====Summary Table:----
Key Takeaways:---
# Use include/include_once when the file is optional.
# Use require/require_once when the file is necessary for the script to run
correctly.
# Use once versions to avoid re-including files and ensure code is loaded only
once.
# This makes code management easier, especially in large projects where
multiple files depend on shared resources!
=======================================================================INTERFACE
PHP CONCEPT =====================================================
Summary:---
1. Definition और Purpose
* Interface: िसफ method declarations रखता है , method के body को define नहीं करता। इसका
उपयोग पू री तरह से "contract" दे ने के िलए होता है िजसे implementing classes follow करती ह।
* Abstract Class: इसम method declarations के साथ method का कुछ implementation भी हो
सकता है । इसका उपयोग inheritance और base classes बनाने के िलए होता है ।
2. Method Implementation
* Interface: इसम सभी methods िबना implementation के होते ह, यानी कोई भी code method body म
नहीं होता।
* Abstract Class: इसम कुछ methods implement िकए जा सकते ह, और कुछ methods िसफ declared
िकए जा सकते ह (abstract methods)।
3. Properties (Variables)
* Interface: Interface म properties define नहीं कर सकते, केवल methods define की जाती ह।
* Abstract Class: Abstract class म properties को define कर सकते ह, िज child
classes access और inherit कर सकती ह।
4. Multiple Inheritance
* Interface: एक class एक से ादा interfaces implement कर सकती है । यह PHP म multiple
inheritance की कमी को पू रा करता है ।
* Abstract Class: एक class केवल एक ही abstract class को extend कर सकती है ।
Summary Table:------
Feature Interface
Abstract Class
Method Implementation Methods without body
Can have both implemented & unimplemented methods
Properties Not allowed
Allowed
Multiple Inheritance Yes (multiple interfaces allowed)
No (only one abstract class allowed)
Access Modifiers Only public
public, protected, private
Usage To define a strict contract
To define common functionality with some default behavior
Conclusion
Interface का उपयोग तब कर जब केवल structure या "contract" की ज रत हो।
Abstract Class का उपयोग तब कर जब कुछ default implementation चािहए हो, और child classes
को कुछ specific methods implement करने के िलए बा करना हो।
====================================== ABSTRACT IN PHP
=============================
In PHP, an abstract class is a class that cannot be instantiated on its own and
is intended to be extended by other classes. It serves as a base class that
provides a common structure for its subclasses while allowing them to implement
specific functionality.
1) Definition:
2) Purpose:
* Abstract classes are used when you want to provide a base class with some
default behavior that can be shared among multiple subclasses.
* They enforce that certain methods must be implemented in the derived classes.
3) Abstract Methods:
* An abstract method is declared without any implementation.
* Any class that extends an abstract class must implement all of its abstract
methods.
4)Concrete Methods:
* These are regular methods that can have their own implementation in the
abstract class.
* Subclasses can either use these methods as-is or override them.
* Example of Abstract Class
Here’s a simple example to illustrate how abstract classes work:
php
Copy code
// Define an abstract class
abstract class Animal {
// Abstract method (no implementation)
abstract public function makeSound();
// Concrete method
public function sleep() {
echo "Sleeping...\n";
}
}
// Calling methods
$dog->makeSound(); // Output: Bark
$dog->sleep(); // Output: Sleeping...
# Abstract Class:
# Subclassing:
# Method Implementation:
When creating instances of Dog and Cat, you can call both the makeSound() method
(which is specific to each animal) and the sleep() method (inherited from
Animal).
Important Notes
* Cannot Instantiate: You cannot create an instance of an abstract class
directly. For example, new Animal(); would throw an error.
* Mixing Concrete and Abstract: You can mix concrete methods and abstract
methods in an abstract class, providing flexibility in your design.
^^^^^^^^^^^^^^^^^^^^^POLYMORPHISM POLYMORPHISM
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1) Definition:
3)Advantages:
Code reusability: The same method can be used for different objects, leading to
cleaner and more manageable code.
Flexibility and maintainability: It allows programmers to write more flexible
and extensible code.
Conclusion:--
Polymorphism is a powerful feature in OOP that enhances code flexibility and
reusability. By allowing methods to behave differently based on the object
calling them, you can write more dynamic and maintainable code. In interviews,
explaining polymorphism with a clear example like the one above will help you
convey your understanding effectively!
Key Points:
2. Method Overloading
Definition:
* Method overloading is a feature that allows the same method name to have
different behaviors based on the number or type of parameters passed to it.
However, PHP does not support method overloading in the same way that languages
like Java or C# do.
Key Points:
Conclusion:-
* Overriding allows subclasses to provide specific implementations of methods
defined in parent classes, enabling runtime polymorphism.
* Overloading, while not directly supported in PHP, can be simulated using
default parameters or variable-length arguments to achieve similar
functionality.
* Understanding both concepts enhances your ability to write flexible and
maintainable PHP code while taking advantage of polymorphism.
Key Points
* Data Hiding:
Encapsulation helps in hiding the internal state of an object from the outside
world.
Only the class itself can access its private and protected properties or
methods, which prevents external entities from altering them directly.
* Access Modifiers:
class Person {
// Private properties
private $name;
private $age;
Conclusion:--
Encapsulation in PHP enhances data security and integrity by restricting access
to the internal state of objects. It allows you to control how data is accessed
and modified, thereby improving code maintainability and reducing the risk of
unintended interference with the object's state. Understanding and implementing
encapsulation is crucial for writing robust object-oriented PHP applications.
* Magic functions in PHP are special functions that start with double
underscores (__). They enable you to perform certain
actions automatically when certain events occur in your code. These functions
are often used in classes to implement behavior
for various operations. Here’s a list of commonly used magic functions in PHP
with explanations and examples:
1. __construct()
* Purpose: This is the constructor method, automatically called when an object
of the class is created.
* Usage: Used for initializing object properties.
class Car {
public function __construct() {
echo "Car object created!\n";
}
}
2. __destruct()
* Purpose: This is the destructor method, automatically called when an object
is destroyed or goes out of scope.
* Usage: Used for cleanup tasks, like closing database connections.
class Car {
public function __destruct() {
echo "Car object destroyed!\n";
}
}
3. __get($name)
* Purpose: Called when trying to access a property that is not accessible or
does not exist.
* Usage: Used to retrieve values of inaccessible or non-existing properties.
class Person {
private $name = "John Doe";
4. __set($name, $value)
* Purpose: Called when trying to set a value to a property that is not
accessible or does not exist.
* Usage: Used to set values of inaccessible or non-existing properties.
class Person {
private $data = [];
5. __isset($name)
* Purpose: Called when using isset() on inaccessible or non-existing
properties.
* Usage: Used to check if a property is set.
class Person {
private $data = ['name' => 'John'];
class Person {
private $data = ['name' => 'John'];
7. __call($name, $arguments)
* Purpose: Called when trying to call a method that is inaccessible or does not
exist.
* Usage: Used to implement dynamic method calls.
class Person {
public function __call($name, $arguments) {
echo "Method $name called with arguments: " . implode(', ', $arguments)
. "\n";
}
}
8. __callStatic($name, $arguments)
* Purpose: Called when trying to call a static method that is inaccessible or
does not exist.
* Usage: Used for dynamic static method calls.
class Person {
public static function __callStatic($name, $arguments) {
echo "Static method $name called with arguments: " . implode(', ',
$arguments) . "\n";
}
}
9. __toString()
* Purpose: Called when an object is treated as a string, for example, when
using echo.
* Usage: Used to define how an object should be represented as a string.
class Person {
public function __toString() {
return "I am a Person object.\n";
}
}
10. __invoke()
* Purpose: Called when an object is used as a function.
* Usage: Allows you to define behavior for when an object is called as a
function.
class Greeting {
public function __invoke($name) {
return "Hello, $name!";
}
}
11. __clone()
* Purpose: Called when an object is cloned.
* Usage: Used to define custom behavior when an object is cloned.
class Person {
public $name;
* Conclusion:----
Magic functions in PHP provide a powerful way to manage object behavior and
enforce encapsulation. Understanding and utilizing these functions can enhance
your object-oriented programming skills, allowing for cleaner and more
maintainable code.
1. What is SQL?
* Definition: SQL (Structured Query Language) is a standard programming
language used to manage and manipulate relational databases.
* Purpose: It allows users to perform operations like querying, updating, and
managing data.
2. SQL Components
a) DDL (Data Definition Language): Commands that define the database
structure.
Here’s a simple overview of common SQL data types and their typical storage
ranges:
c) Inserting Data: INSERT INTO students (name, age, grade) VALUES ('John
Doe', 15, '10th Grade');
e) Updating Data: UPDATE students SET age = 16 WHERE name = 'John Doe';
4. SQL Clauses
a) WHERE: Filter records based on specific conditions.
SELECT * FROM students WHERE age > 14;
5. SQL Functions
a) Aggregate Functions: Perform calculations on a set of values.
sql code:------
SELECT COUNT(*) FROM students;
SELECT AVG(age) FROM students;
sql code:---
SELECT UPPER(name) FROM students;
SELECT CONCAT(name, ' ', grade) FROM students;
c) Date Functions: Manipulate date values.
sql code:--
SELECT NOW();
SELECT CURDATE();
6. Joins
a) INNER JOIN: Combines rows from two or more tables based on a related
column.
sql code
SELECT students.name, courses.course_name
FROM students
INNER JOIN courses ON students.id = courses.student_id;
b) LEFT JOIN: Returns all rows from the left table and matched rows from the
right table.
sql code
SELECT students.name, courses.course_name
FROM students
LEFT JOIN courses ON students.id = courses.student_id;
c) RIGHT JOIN: Returns all rows from the right table and matched rows from the
left table.
sql code
SELECT students.name, courses.course_name
FROM students
RIGHT JOIN courses ON students.id = courses.student_id;
d) FULL OUTER JOIN: Returns all rows when there is a match in either left or
right table.
sql code
SELECT students.name, courses.course_name
FROM students
FULL OUTER JOIN courses ON students.id = courses.student_id;
7. Subqueries
Definition: A query nested inside another query.
Example:
sql code
SELECT name FROM students WHERE id IN (SELECT student_id FROM courses WHERE
course_name = 'Math');
8. Transactions
Definition: A sequence of operations performed as a single unit.
Example:
sql code
START TRANSACTION;
INSERT INTO accounts (balance) VALUES (100);
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
COMMIT; // or ROLLBACK to undo
9. Constraints
NOT NULL: Ensures that a column cannot have a NULL value.
UNIQUE: Ensures that all values in a column are different.
PRIMARY KEY: Uniquely identifies each row in a table.
FOREIGN KEY: Enforces a link between the data in two tables.
10. Indexing
Definition: A data structure that improves the speed of data retrieval
operations.
Example:
sql code
CREATE INDEX idx_name ON students(name);
Conclusion
This overview provides a foundational understanding of SQL and its essential
concepts. With practice, you can effectively use SQL to interact with databases
and manage data efficiently.
2) Event Handling:
* jQuery makes it easy to send asynchronous requests to the server and update
parts of a web page without reloading.
* Example: Sending an AJAX request to fetch data from a server.
$.ajax({
url: "data.php",
method: "GET",
success: function(data) {
$("#result").html(data);
}
});
$(document).ready(function() {
$("#myElement").fadeOut(1000); // Fades out over 1 second
});
5) CSS Manipulation:
6) Chaining:
$("#myDiv").css("color", "red").slideUp(2000).slideDown(2000);
<form id="myForm">
<input type="text" name="username" required>
<button type="submit">Submit</button>
</form>
<div id="response"></div>
<script>
$(document).ready(function() {
$("#myForm").submit(function(event) {
event.preventDefault(); // Prevent default form submission
$.ajax({
url: "process.php",
method: "POST",
data: $(this).serialize(),
success: function(data) {
$("#response").html(data);
}
});
});
});
</script>
*Conclusion:----
jQuery is a powerful tool for simplifying web development. Its ability to
manipulate the DOM, handle events, and communicate with servers makes it an
essential part of many web applications. When combined with PHP, jQuery can
create dynamic and responsive user interfaces, enhancing the overall user
experience.
2. Keyboard Events
keydown: Triggered when a key is pressed down.
keyup: Triggered when a key is released.
keypress: Triggered when a key is pressed and released.
3. Form Events
focus: Triggered when an element (like an input) gains focus.
blur: Triggered when an element loses focus.
change: Triggered when the value of an input, select, or textarea is changed.
submit: Triggered when a form is submitted.
select: Triggered when text inside an input or textarea is selected
4. Document/Window Events
6. Animation Events
show: Shows an element with animation.
hide: Hides an element with animation.
toggle: Toggles the visibility of an element.
fadeIn/fadeOut: Fades an element in or out.
slideDown/slideUp: Slides an element up or down.
7. Other Events
on: Binds an event handler to an element.
off: Removes an event handler from an element.
one: Attaches an event that runs only once.
********************************************************************************
*********************
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ JQUERY
CONCEPT
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}]
1. jQuery ा है ?
* jQuery एक ी, ओपन-सोस JavaScript लाइ ेरी है ।
* इसका इ े माल HTML डॉ ूमट को आसानी से manipulate करने , इवट् स को हडल करने , और एनीमे शन बनाने के िलए होता
है ।
* इसका मु उ े JavaScript को आसान बनाना है ।
3. Selector ा होता है ?
* jQuery म Selector का उपयोग HTML एिलमट् स को िसले करने के िलए िकया जाता है ।
* उदाहरण:
* ID Selector: $("#myId") - इस से HTML एिलमट िसले होगा िजसका ID "myId" है ।
* Class Selector: $(".myClass") - इस से सभी एिलमट् स िसले होंगे िजनकी ास "myClass" है ।
* Tag Selector: $("p") - यह सभी <p> टै को िसले करे गा।
5. Animation Effects
* jQuery का इ े माल एनीमेशन जैसे इफ़े ् स के िलए भी िकया जा सकता है ।
* उदाहरण:
* Hide/Show: $("#myElement").hide(); या $("#myElement").show();
* Fade: $("#myElement").fadeIn(); या $("#myElement").fadeOut();
* Slide: $("#myElement").slideUp(); या $("#myElement").slideDown();
6. AJAX
* jQuery AJAX कॉ को आसान बनाता है , िजससे आप िबना पेज को री े श िकए सवर से डे टा मंगवा सकते ह।
* उदाहरण:
$.ajax({
url: "data.json",
success: function(result){
$("#myDiv").html(result);
}
});
8. DOM Manipulation
* jQuery के ारा HTML एिलमट् स को एड, रमूव, और चज िकया जा सकता है ।
* उदाहरण:
* HTML कंटट बदलना: $("#myDiv").html("नया कंटट");
* एिलमट जोड़ना: $("body").append("<p>नया पै रा ाफ</p>");
* ाइल बदलना: $("#myDiv").css("color", "red");
* jQuery को अपनी वेबसाइट म जोड़ने के िलए CDN िलंक का उपयोग िकया जा सकता है ।
* उदाहरण:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
jQuery की मदद से आप आसानी से और तेज़ी से वेब पे ज म इं टरे व फीचस जोड़ सकते ह।
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AJAX Example</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<h2>AJAX Form Submission</h2>
<form id="myForm">
<input type="text" name="username" placeholder="Enter your name"
required>
<button type="submit">Submit</button>
</form>
<div id="response"></div>
<script>
$(document).ready(function() {
$("#myForm").submit(function(event) {
event.preventDefault(); // Prevent the form from submitting
normally
$.ajax({
url: "process.php", // The URL to the PHP script
type: "POST",
data: $(this).serialize(), // Serialize the form data
success: function(data) {
$("#response").html(data); // Update the page with the
response
}
});
});
});
</script>
</body>
</html>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = htmlspecialchars($_POST['username']); // Sanitize user input
echo "Hello, " . $username . "! Your form was submitted successfully.";
} else {
echo "Invalid request.";
}
?>
* HTML Form: The form captures user input (username) and prevents the default
submission using jQuery.
* AJAX Request: On form submission, an AJAX request is sent to process.php with
the input data.
* PHP Script: The PHP script processes the data and returns a response, which
is displayed on the same page without a full refresh.
Conclusion:=
* AJAX enhances web applications by allowing for asynchronous data exchange
between the client and server. By combining AJAX with PHP, developers can create
dynamic, interactive web pages that respond quickly to user actions,
significantly improving the overall user experience.
******************************************************************************
===================================================================AJAX CONCEPT
resume maker, inheance cv ,
================================================================================
==
1. AJAX ा है ?
* AJAX का मतलब Asynchronous JavaScript and XML है ।
* यह एक तकनीक है िजससे वेब पे ज र े श िकए िबना ही सवर से डे टा भे जा और ा िकया जा सकता है ।
* इससे वेब ए केशन अिधक तेज और इं टरै व बनती है ।
3. AJAX के मु फायदे
* ीड: पे ज को बार-बार लोड नहीं करना पड़ता, इसिलए लोिडं ग का समय कम होता है ।
* बडिवड् थ की बचत: केवल आव क डे टा ही सवर से मंगाया जाता है ।
* यू ज़र ए पी रयंस: वेबसाइट अिधक इं टरै व और र ॉ व बनती है ।
5. AJAX का िसंटै
* AJAX कॉल करने के िलए िसंपल जावा कोड इस तरह से िलखा जा सकता है :
$.ajax({
url: "data.txt",
type: "GET",
success: function(result) {
$("#myDiv").html(result);
}
});
* यहाँ url से सवर पर र े भे जी जा रही है , और जब डे टा वापस आता है , तो success फ़ं न म #myDiv के HTML को
अपडे ट कर िदया जाता है ।
7. AJAX Methods
* $.get(): डे टा को GET तरीके से ा करता है ।
* $.post(): डे टा को POST तरीके से सवर पर भे जता है ।
* $.load(): िकसी HTML एिलमट म डे टा लोड करने के िलए उपयोग होता है ।
$.getJSON("data.json", function(data) {
$.each(data, function(key, value) {
$("#myDiv").append(key + ": " + value + "<br>");
});
});
* यहाँ , data.json से डे टा ा होता है और $.each() का उपयोग करके हर एक डे टा आइटम को वे ब पे ज पर जोड़ा जाता
है ।
$.ajax({
url: "data.txt",
type: "GET",
success: function(result) {
$("#myDiv").html(result);
},
error: function(xhr, status, error) {
alert("Error: " + error);
}
});
* अगर िकसी कारणवश डे टा नहीं िमलता, तो error फ़ं न म एरर मैसेज िदखाया जा सकता है ।
* AJAX से वेब ए केशन अिधक डायनािमक और इं टरै व बनती है , िजससे यूजर ए पी रयंस और भी बेहतर होता है ।
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CURL CONCEPT
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
cURL (Client URL) का कॉ े PHP म एक ब त उपयोगी टू ल है , िजसका उपयोग हम इं टरनेट से डे टा ा करने , API
कॉल करने और दू सरे सवर से कने करने के िलए करते ह। इसे आसान भाषा म समझते ह:
cURL का बेिसक कॉ े
cURL एक PHP लाइ ेरी है जो HTTP/HTTPS ोटोकॉल का उपयोग करके वे ब सवर से डे टा भे जने या ा करने की सुिवधा दे ती
है ।
यह API डे टा ा करने , फाइल डाउनलोड करने , और फॉम डे टा सबिमट करने जै से काय म मदद करता है ।
cURL के मह पू ण े
cURL Initialize करना:
curl_setopt() फं न का उपयोग करके cURL के ऑ शन सेट िकए जाते ह। ये ऑ शंस बताते ह िक ा करना है और कैसे
करना है ।
जै से URL सेट करना, रटन वै ू ा करना, डे टा भे जना आिद।
php
Copy code
curl_setopt($curl, CURLOPT_URL, "https://api.example.com");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
cURL Execute करना:
अगर कोई एरर आती है तो curl_error() फं न से उसे हडल िकया जा सकता है और अं त म curl_close() से cURL
सेशन को बंद करना होता है ।
php
Copy code
if($response === false) {
echo "Error: " . curl_error($curl);
}
curl_close($curl);
cURL के उपयोग के फायदे
API कॉल करना: API से डे टा ा करने और भे जने म मदद करता है ।
वेब ै िपं ग: HTML पे ज का डे टा ा कर सकते ह।
फाइल डाउनलोड/अपलोड: सवर से फाइल डाउनलोड या अपलोड कर सकते ह।
उदाहरण
php
Copy code
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://jsonplaceholder.typicode.com/posts");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
इस कोड म, हमने एक API से डे टा ा िकया और उसे ीन पर िदखाया।
Summary
cURL का उपयोग डे टा के आदान- दान और API इं टरे न के िलए होता है , िजससे सवर से कने करना और डे टा भे जना या ा
करना आसान हो जाता है ।
********************************************************************************
********************************************************************************
*
PHP म फाइल हडिलंग का मतलब है िक हम फाइ को पढ़ सकते ह, िलख सकते ह, बना सकते ह, िडलीट कर सकते ह और एिडट
कर सकते ह। यह ब त उपयोगी होता है जब हम िकसी वेबसाइट पर डे टा को फाइ म ोर करना या उसे ए े स करना होता है ।
आसान भाषा म इसे समझते ह:
// फाइल म डे टा िलखना
if ($file) {
fwrite($file, "This is a sample text.\n");
fclose($file); // फाइल को बंद करना
}
// फाइल को पढ़ना
$file = fopen("myfile.txt", "r");
if ($file) {
while (($line = fgets($file)) !== false) {
echo $line; // लाइन बाई लाइन पढ़कर ि ं ट करना
}
fclose($file); // फाइल को बंद करना
}
Summary
PHP फाइल हडिलंग म फाइ को ओपन, रीड, राइट, और िडलीट करना शािमल है । यह िकसी भी कार के डे टा को फाइल म ोर
या ए े स करने म मदद करता है ।
* The Document Object Model (DOM) is a programming interface for web documents.
It represents the structure of a document as a tree of objects.
* The DOM allows programming languages, like JavaScript, to interact with the
content, structure, and style of a web page.
Tree Structure:
* The DOM represents the HTML document as a tree structure where each node is an
object representing a part of the document (elements, attributes, text, etc.).
* For example, an HTML document with nested elements would look like a tree:
Document
├── html
├── head
├── body
├── div
├── p
└── ul
├── li
└── li
Accessing Elements:
JavaScript can access and manipulate DOM elements using various methods.
Example:
const element = document.getElementById("myElement");
const items = document.getElementsByClassName("item");
const firstItem = document.querySelector(".item");
Manipulating Elements:
You can modify the content, attributes, and styles of DOM elements.
* Changing Content: Use innerHTML or textContent.
* Changing Attributes: Use setAttribute() or access properties directly.
* Changing Styles: Modify the style property.
Example:
// Change content
element.innerHTML = "New Content";
// Change an attribute
element.setAttribute("class", "newClass");
// Change style
element.style.color = "blue";
Creating and Removing Elements:
You can create new elements and add them to the DOM using createElement() and
appendChild().
You can also remove elements using removeChild().
Example:
// Remove an element
const parent = document.getElementById("parentElement");
parent.removeChild(newElement);
Event Handling:
* The DOM allows you to listen for and respond to events (like clicks, mouse
movements, form submissions).
* You can use addEventListener() to attach event handlers.
* Example:
const button = document.getElementById("myButton");
button.addEventListener("click", function() {
alert("Button clicked!");
});
* You can navigate through the DOM tree using properties like parentNode,
childNodes, firstChild, lastChild, and nextSibling.
* Example:
Conclusion:----
* The DOM is a crucial concept in web development, allowing JavaScript to
dynamically interact with HTML documents.
Understanding how to access, manipulate, and respond to events in the DOM is
essential for creating interactive web
applications.
* With the DOM, developers can enhance user experiences by dynamically
updating content, styles, and structures
without reloading the entire page.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Laravel एक लोकि य PHP framework है जो web application development को सरल, तेज, और अिधक
संगिठत बनाता है । यहाँ Laravel के बारे म कुछ मह पू ण िबंदु िदए गए ह:
Laravel के मु िबंदु:
MVC आिकटे र:
Laravel database migration का समथन करता है , जो database schema को version control करने
की अनुमित दे ता है ।
आप आसानी से database tables को create, modify, या delete कर सकते ह।
Blade Template Engine:
Laravel का Blade template engine HTML म PHP को िलखने का एक सरल तरीका दान करता है ।
Blade syntax ब त आसान और साफ है , िजससे UI development म सुिवधा होती है ।
Middleware:
Laravel testing के िलए built-in support दान करता है । आप PHPUnit का उपयोग करके अपने
application के िलए automated tests िलख सकते ह।
Community and Ecosystem:
ChatGPT
Laravel के Artisan commands ब त उपयोगी होते ह और ये web application development के िविभ
tasks को automate करने म मदद करते ह। यहाँ Laravel के कुछ मुख Artisan commands की सूची दी गई है :
php artisan help: िकसी भी Artisan command के िलए help दिशत करता है ।
php artisan list: सभी उपल Artisan commands की सूची िदखाता है ।
Environment Commands:
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ JAVASCRIPT
CONCEPT
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
]]]]]]]]]]]]
JavaScript के मह पू ण Concepts
1. JavaScript ा है ?
JavaScript एक scripting language है जो web pages को interactive और dynamic बनाने के िलए
उपयोग होती है ।
इसे Netscape ारा develop िकया गया था और अब यह एक standard है , िजसे ECMAScript कहा जाता है ।
function greet(name) {
return "Hello, " + name;
}
console.log(greet("John")); // Output: Hello, John
13. Objects (ऑ े ् स)
Objects म key-value pairs होते ह और इ complex data structures के प म उपयोग िकया जाता है ।
Example:
let person = {
name: "John",
age: 30,
greet: function() {
return "Hello, " + this.name;
}
};
console.log(person.greet()); // Output: Hello, John
Summary:-----
JavaScript एक versatile और powerful language है जो web development को interactive
और dynamic बनाती है । इसके मु concepts को समझने से आप अपनी web applications म features जोड़
सकते ह। JavaScript का अ ास करते रह और अपने skills को enhance कर!