0% found this document useful (0 votes)
10 views47 pages

Mix PHP Opps All Notes

Php & opps basic notes

Uploaded by

Sonu zehen001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views47 pages

Mix PHP Opps All Notes

Php & opps basic notes

Uploaded by

Sonu zehen001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

______________________________________________INTRODUCTION

__________________________________________________ FOR INTERVIEW :-


"Hello, myself sonu kumar pandey Basically i am from Bihar , and I recently
postgraduate from imsec college ghaziabad with a degree in mca .
I have complete bca from patna university . "I have core background in PHP,
html bootstrap ,JavaScript, MySQL , laravel,jquery ], and
I’m also familiar with tools like Git, VS Code xampp Server. I have worked on
web development and back-end technologies."During my studies,
I worked on a few projects that helped me develop practical skills. One project
"I completed a project called a Student Management System,
where I built an application using PHP and MySQL to manage student & teacher
records. This project taught me about database integration
and helped me improve my coding skills. I also developed a Bank Management
System, where I used AJAX and jQuery to create an interactive
user experience."
These projects allowed me to gain hands-on experience in both front-end and
back-end development. Additionally,
I completed training sessions on web development using php,mysql,js, & ajax.
I’m eager to continue learning and
applying my skills, and I’m excited about the opportunity to contribute to your
team.""I’m passionate about building
applications that solve real-world problems, and I’m excited to start my career
in a position where I can continue learning
and contributing. I believe that working here would be an ideal environment to
grow and apply my skills."

**"Goodafternoon, my name is Sonu Kumar Pandey, I recently completed


MCA from IMSEC College, Ghaziabad with 8 cgpa,

// 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.

my long term goal is to be successful professionally with a focus on


continuous growth and contribution. My hobby are including Fitness Activities
( Yoga, Running) ,Traveling ,Learning New Technologies . My interest in this
field because I always want to work in theses technologies & integrated systems
that
why I did MCA.I love to see how the technologies drive the world. thanks to
giving me opportunity for introduction.
// I have a core background in PHP, HTML, Bootstrap, JavaScript, MySQL,
Laravel, and jQuery.

**"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 (Hypertext Preprocessor) एक सवर-साइड ि ं ग ल े ज है िजसका उपयोग मु प से डायनािमक वेब


पे ज और वेब ए केश बनाने के िलए िकया जाता है । यह ओपन-सोस है और आसानी से HTML के साथ इं टी े ट हो जाती है । PHP
की मुख िवशेषताएं इस कार ह:

* सवर-साइड: 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.

Key Features of PHP:


1) Easy to Learn: PHP has a simple syntax, making it beginner-friendly.
2) Server-Side Execution: PHP code runs on the server, and the result is sent
to the user’s web browser.
3) Open-Source: PHP is free and widely supported with a large community of
developers.
4) Database Integration: It works well with databases like MySQL, making it
ideal for building data-driven websites.
5) Cross-Platform Compatibility: PHP code can run on various operating systems,
such as Windows, macOS, and Linux.

How PHP Works:

1) Server-Side Processing: When a user requests a PHP page, the server


processes the PHP code.
2) HTML Output: The server generates HTML as output and sends it to the user’s
browser.
Example:
<?php
echo "Hello, world!";
?>
When this code runs on the server, the browser receives Hello, world! as the
result.

Common Uses of PHP:

* 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 Learn PHP?


* Popular for Web Development: Many popular websites and applications use PHP.
* Integration with HTML and CSS: PHP works seamlessly with HTML and CSS to
build websites.
* Backend Skills: Knowing PHP helps you build the backend (server-side) of
websites.
PHP is a powerful tool for web development, especially if you want to build
dynamic, data-driven websites!
====================================

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:----

* String Creation: Use quotes, either ' ' or " ".


* String Functions: Use functions like strlen, strrev, strpos, etc., for
common operations.
* Concatenation: Use . to join strings.
These functions make it easy to manipulate and work with strings in PHP!
Summary:
* Basic Operations: strlen, strrev, str_word_count
* Finding/Replacing Text: strpos, str_replace
* Formatting: strtolower, strtoupper, ucfirst, ucwords
* Whitespace and Parts: trim, substr
* Repetition: str_repeat
These functions make it easy to handle text in PHP!

===================================================

Summary of PHP Magic Constants:


* __LINE__: Current line number in the script.
* __FILE__: Full path and filename of the file.
* __DIR__: Directory of the file.
*
__FUNCTION__: Name of the function.
* __CLASS__: Name of the class.
* __METHOD__: Name of the method in a class.
* __NAMESPACE__: Name of the current namespace.
These constants are handy for debugging, organizing files, and managing
functions and classes in PHP.

=========================================================================

Summary of PHP Operators:


* Arithmetic: +, -, *, /, %
* Assignment: =, +=, -=, *=, /=, %=
* Comparison: ==, !=, >, <, >=, <=
* Logical: &&, ||, !
* Increment/Decrement: ++, --
* String: ., .= for concatenation
* Ternary: condition ? value_if_true : value_if_false
* These operators make it easy to handle values, conditions, and text in PHP.

=============================================================

Summary of PHP Conditional Concepts:


* If Statement: Checks a condition and executes code if true.
* If...Else Statement: Executes code if the condition is false.
* If...Else If...Else Statement: Checks multiple conditions.
* if-elseif-else: जब कई कंडीशंस चेक करनी हो।
* Nested if-else: जब एक if या else के अंदर एक और if-else हो।

* Switch Statement: Compares a variable to multiple values.


* Ternary Operator: A shorthand for if...else.
These conditional statements allow you to control the flow of your PHP programs
based on various conditions, making your code more dynamic and responsive.
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.

* Anonymous Functions: Create unnamed functions for specific use cases.


Using functions effectively in PHP makes code efficient, organized, and easier
to understand.

================ MAGIC FUNCTIONS IN PHP:- ====================


Summary of PHP Magic Functions:--

* 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 = [];

public function __get($name) {


return $this->properties[$name] ?? "Property not found";
}
}

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:

$myCar->color = "blue"; // if color is inaccessible

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:

unset($myCar->color); // if color is inaccessible

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:

Car::drive(); // if drive() static method is undefined

9. __toString()

* Purpose: Called when an object is treated as a string (e.g., echo).


* Usage: Format the output when echoing an object.
* Example:
echo $myCar; // Converts object to string

10. __invoke()
* Purpose: Triggered when trying to call an object as a function.
* Usage: Use an object like a function.
* Example:

$myCar(); // if object is called like a function

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);

14. __serialize() and __unserialize() (PHP 7.4+)


* Purpose: Custom behavior during serialization and unserialization.
* Usage: Replaces __sleep() and __wakeup() with more control.
* Example:
serialize($myCar);
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);

17. __autoload() (Deprecated; use spl_autoload_register)


* Purpose: Automatically loads undefined classes.
* Usage: Not recommended; replaced by spl_autoload_register.

------------------------------------------------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.

--------------- INHERITANCE IN OOPS ----------

Key Points about Inheritance in PHP--------------:

# Parent Class: The class being inherited from.


# Child Class: The class that inherits from the parent.
# extends Keyword: Used to inherit a parent class.
# parent::method(): Access parent methods from within the child class.
# final Keyword: Prevents a class or method from being inherited or overridden.

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!";
}
}

class Dog extends Animal {


public function makeSound() {
echo "Dog barks!";
}
}

$dog = new Dog();


$dog->makeSound(); // Output: Dog barks!

2..) Protected Members: Protected ॉपट ज़ और मेथड् स केवल उसी ास म या उन ासे स म ए े स िकए जा
सकते ह जो उसे इनहे रट करती ह।
class Animal {
protected $name;

protected function setName($name) {


$this->name = $name;
}
}

class Dog extends Animal {


public function setDogName($name) {
$this->setName($name);
echo "Dog name is: " . $this->name;
}
}

$dog = new Dog();


$dog->setDogName("Max"); // Output: Dog name is: Max

3..)Final Keyword: अगर िकसी ास या मे थड को final घोिषत िकया गया है , तो उसे आगे इनहे रट या ओवरराइड
नहीं िकया जा सकता।
class Animal {
final public function makeSound() {
echo "Animal sound!";
}
}

class Dog extends Animal {


// Cannot override makeSound method as it is declared final in Animal class
}

// This will throw an error if you try to override makeSound method in Dog
class.

Single Inheritance: एक derived ास एक बे स ास से इनहे रट करती है ।


Multilevel Inheritance: एक derived ास दू सरी derived ास से इनहे रट करती है ।
Hierarchical Inheritance: एक बेस ास से कई derived ासे स इनहे रट कर सकती ह।

--------------------TRAITS TRAITS TRAITS


--------

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!

--------------------NAMESPACES IN PHP -----------------------

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!

=======================================INCLUDE, INCLUDE ONCE, REQUIRE


,,,,REQUIRE ONCE:========================

====Summary Table:----

Keyword Behavior When Missing


Loads File Only Once?
include Shows a warning, continues
No
include_once Shows a warning, continues
Yes
require Fatal error, stops execution
No
require_once Fatal error, stops execution
Yes

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 =====================================================

Key Rules for Interfaces:-----------

* Methods must be public: All methods in an interface are public by default.


* No properties: Interfaces cannot contain properties.
* Multiple Interfaces: A class can implement multiple interfaces, which is a
way to get around the lack of multiple inheritance in PHP.
* Example of Multiple Interfaces

Summary:---

* Interfaces define required methods without implementations.


* Classes implementing an interface must define all methods in the interface.
* Multiple interfaces can be implemented by a single class for flexible design.
* Interfaces are great for standardizing method names across different classes,
making it easier to work with code that has consistent structure!
---------------------------------INTERFACE VS ABSTRACTION
:--------------------------

In PHP, Interface और Abstract Class दोनों का उपयोग अ classes के िलए एक structure


provide करने के िलए होता है । परं तु दोनों म कुछ मह पू ण अंतर ह, जो उनके उपयोग को अलग-अलग प र ितयों म उपयु
बनाते ह।

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 कर सकती है ।

5. Access Modifiers (public, private, protected)


* Interface: Interface methods को िसफ public declare कर सकते ह। Interface म private
या protected methods नहीं हो सकते।
* Abstract Class: Abstract class के methods public, protected, या private हो सकते ह।

6. Usage (कब Use कर?)


* Interface: जब केवल methods का structure define करना हो, और कोई base implementation
नहीं चािहए।
* Abstract Class: जब कुछ common functionality provide करनी हो िजसे child classes
inherit कर सक।
उदाहरण से समझ
Interface Example
php
Copy code
interface Animal {
public function makeSound();
}

class Dog implements Animal {


public function makeSound() {
echo "Bark";
}
}

class Cat implements Animal {


public function makeSound() {
echo "Meow";
}
}
Abstract Class Example
php
Copy code
abstract class Animal {
public $name;

public function __construct($name) {


$this->name = $name;
}

abstract public function makeSound();

public function getName() {


return $this->name;
}
}

class Dog extends Animal {


public function makeSound() {
echo "Bark";
}
}

class Cat extends Animal {


public function makeSound() {
echo "Meow";
}
}

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.

Key Points of Abstract Classes

1) Definition:

* An abstract class is defined using the abstract keyword.


* It can contain both abstract methods (without a body) and concrete methods
(with a body).

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";
}
}

// Subclass Dog extending the abstract class


class Dog extends Animal {
// Implementing the abstract method
public function makeSound() {
echo "Bark\n";
}
}

// Subclass Cat extending the abstract class


class Cat extends Animal {
// Implementing the abstract method
public function makeSound() {
echo "Meow\n";
}
}

// Creating instances of subclasses


$dog = new Dog();
$cat = new Cat();

// Calling methods
$dog->makeSound(); // Output: Bark
$dog->sleep(); // Output: Sleeping...

$cat->makeSound(); // Output: Meow


$cat->sleep(); // Output: Sleeping...

Explanation of the Example

# Abstract Class:

The Animal class is declared as an abstract class. It contains one abstract


method (makeSound()) and one concrete method (sleep()).

# Subclassing:

The Dog and Cat classes extend the Animal class.


Each subclass must implement the makeSound() method.

# 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.

* Enforcing Structure: Abstract classes enforce a certain structure on the


subclasses, ensuring that they implement required methods.

* Mixing Concrete and Abstract: You can mix concrete methods and abstract
methods in an abstract class, providing flexibility in your design.

When to Use Abstract Classes


* Use abstract classes when you want to define a common interface and shared
functionality for a group of related classes but still require some specific
behavior to be defined in each subclass.
* They are particularly useful in large applications where many classes share
similar behaviors but need to provide different implementations for certain
functionalities.
* Abstract classes help in building a clear and maintainable code structure by
promoting the use of inheritance and polymorphism!

^^^^^^^^^^^^^^^^^^^^^POLYMORPHISM POLYMORPHISM
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

olymorphism is a core concept of Object-Oriented Programming (OOP) in PHP (and


other programming languages) that allows objects to be treated as instances of
their parent class, even when they are instances of derived classes. The word
"polymorphism" means "many shapes," and it enables methods to do different
things based on the object that it is acting upon.

Key Points of Polymorphism

1) Definition:

* Polymorphism allows methods to use objects of different classes in a similar


manner. It enables a single function or method to work in different ways
depending on the object it is called on.
2) Types of Polymorphism:

Compile-time Polymorphism (Method Overloading): This is not supported directly


in PHP but can be simulated using different method names or function parameters.
Run-time Polymorphism (Method Overriding): This occurs when a subclass provides
a specific implementation of a method that is already defined in its parent
class.

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.

When to Use Polymorphism:----


Use polymorphism when you want to write code that can work with objects of
different classes but still calls the same method. It is especially useful in
cases where you have multiple classes with similar behavior but different
implementations.

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!

------------------------------------------------------------ Overloading and


Overriding in Polymorphism in PHP---------------------------------
1. Method Overriding
Definition:

* Method overriding occurs when a subclass provides a specific implementation


of a method that is already defined in its parent class. This allows the
subclass to define its own behavior for that method.

Key Points:

* Overriding is used to change or extend the behavior of the parent class.


* It is applicable at runtime (runtime polymorphism).
* Example:

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:

* PHP does not support function overloading directly.


* You can simulate overloading by using default parameters or variable-length
argument lists.

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.

_____________- ***** ENCAPSULATION


ENCAPSULATION___________________________________________________________________
Encapsulation is one of the fundamental principles of Object-Oriented
Programming (OOP). It refers to the bundling of data (attributes) and methods
(functions) that operate on the data into a single unit, typically a class.
Encapsulation restricts direct access to some of an object's components, which
is a means of preventing unintended interference and misuse of the methods and
data.

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:

PHP uses three main access modifiers to control visibility:


* public: Accessible from anywhere.
* protected: Accessible only within the class itself and by inheriting classes.
* private: Accessible only within the class itself.
Getters and Setters:
Example of Encapsulation in PHP

class Person {
// Private properties
private $name;
private $age;

// Constructor to initialize properties


public function __construct($name, $age) {
$this->name = $name;
$this->age = $age;
}

// Getter for name


public function getName() {
return $this->name;
}

// Setter for name


public function setName($name) {
$this->name = $name;
}

// Getter for age


public function getAge() {
return $this->age;
}

// Setter for age


public function setAge($age) {
if ($age >= 0) {
$this->age = $age; // Only set if the age is valid
} else {
echo "Age cannot be negative.\n";
}
}
}

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

* 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";
}
}

$myCar = new Car(); // Output: Car object created!

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";
}
}

$myCar = new Car();


unset($myCar); // Output: Car object destroyed!

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";

public function __get($name) {


return $this->name; // Return name if accessed
}
}

$person = new Person();


echo $person->name; // Output: 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 = [];

public function __set($name, $value) {


$this->data[$name] = $value; // Store value in the array
}
}

$person = new Person();


$person->name = "Jane Doe"; // Sets value using __set

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'];

public function __isset($name) {


return isset($this->data[$name]); // Check if property exists
}
}

$person = new Person();


var_dump(isset($person->name)); // Output: bool(true)
6. __unset($name)
* Purpose: Called when using unset() on inaccessible or non-existing
properties.
* Usage: Used to unset a property.

class Person {
private $data = ['name' => 'John'];

public function __unset($name) {


unset($this->data[$name]); // Remove property from array
}
}

$person = new Person();


unset($person->name); // Calls __unset

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";
}
}

$person = new Person();


$person->sayHello('Hi'); // Output: Method sayHello called with arguments: Hi

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";
}
}

Person::sayHello('Hello'); // Output: Static method sayHello called with


arguments: Hello

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";
}
}

$person = new Person();


echo $person; // Output: I am a Person object.

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!";
}
}

$greet = new Greeting();


echo $greet('John'); // Output: Hello, John!

11. __clone()
* Purpose: Called when an object is cloned.
* Usage: Used to define custom behavior when an object is cloned.

class Person {
public $name;

public function __clone() {


// Custom behavior on clone
$this->name .= " (cloned)";
}
}

$original = new Person();


$original->name = "John";
$copy = clone $original;
echo $copy->name; // Output: John (cloned)

* 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.

{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ SQL CONCEPT


}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

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.

CREATE: Create new databases or tables.


ALTER: Modify existing database structures.
DROP: Delete databases or tables.
b) DML (Data Manipulation Language): Commands for manipulating data.

SELECT: Retrieve data from a database.


INSERT: Add new records to a table.
UPDATE: Modify existing records.
DELETE: Remove records from a table.
c) DCL (Data Control Language): Commands that control access to data.

GRANT: Give user access privileges.


REVOKE: Take away user access privileges.
d) TCL (Transaction Control Language): Commands that manage transactions.

COMMIT: Save changes made during the current transaction.


ROLLBACK: Undo changes made during the current transaction.
SAVEPOINT: Set a point to which you can later roll back.

Here’s a simple overview of common SQL data types and their typical storage
ranges:

1. String Data Types


CHAR(size): Fixed-length string, up to 255 characters.
VARCHAR(size): Variable-length string, up to 65,535 characters (depends on the
database).
TEXT: Holds up to 65,535 characters.
MEDIUMTEXT: Holds up to 16,777,215 characters.
LONGTEXT: Holds up to 4,294,967,295 characters.
2. Numeric Data Types
TINYINT: Range: -128 to 127 (signed) or 0 to 255 (unsigned).
SMALLINT: Range: -32,768 to 32,767 (signed) or 0 to 65,535 (unsigned).
MEDIUMINT: Range: -8,388,608 to 8,388,607 (signed) or 0 to 16,777,215
(unsigned).
INT or INTEGER: Range: -2,147,483,648 to 2,147,483,647 (signed) or 0 to
4,294,967,295 (unsigned).
BIGINT: Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (signed)
or 0 to 18,446,744,073,709,551,615 (unsigned).
FLOAT: Single-precision floating-point; approximate range is ±3.402823466E+38 (7
digits precision).
DOUBLE: Double-precision floating-point; approximate range is
±1.7976931348623157E+308 (15 digits precision).
DECIMAL(p, s): Exact numeric data type for fixed-point numbers. Precision (p)
and scale (s) define the number of digits before and after the decimal.
3. Date and Time Data Types
DATE: Stores dates from '1000-01-01' to '9999-12-31'.
TIME: Stores time from '-838:59:59' to '838:59:59'.
DATETIME: Stores date and time from '1000-01-01 00:00:00' to '9999-12-31
23:59:59'.
TIMESTAMP: Stores date and time from '1970-01-01 00:00:01' UTC to '2038-01-19
03:14:07' UTC.
4. Boolean Data Type
BOOLEAN: Often stored as 1 (TRUE) or 0 (FALSE).
5. Binary Data Types
BLOB: Stores binary data; can hold up to 65,535 bytes.
MEDIUMBLOB: Stores binary data; can hold up to 16,777,215 bytes.
LONGBLOB: Stores binary data; can hold up to 4,294,967,295 bytes.
This overview covers common SQL data types and their ranges, which may vary
slightly by SQL database systems (MySQL, PostgreSQL, etc.).

3. Basic SQL Commands

a) Creating a Database: CREATE DATABASE my_database;

b) Creating a Table: CREATE TABLE students (


id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
age INT,
grade VARCHAR(10)
);

c) Inserting Data: INSERT INTO students (name, age, grade) VALUES ('John
Doe', 15, '10th Grade');

d)Retrieving Data: SELECT * FROM students; // Get all records


SELECT name, age FROM students WHERE grade = '10th
Grade'; // Get specific columns

e) Updating Data: UPDATE students SET age = 16 WHERE name = 'John Doe';

f) Deleting Data: DELETE FROM students WHERE name = 'John Doe';

4. SQL Clauses
a) WHERE: Filter records based on specific conditions.
SELECT * FROM students WHERE age > 14;

b) ORDER BY: Sort the result set.

SELECT * FROM students ORDER BY name ASC; // ASC for ascending,


DESC for descending

c) GROUP BY: Group records that have the same values.

SELECT grade, COUNT(*) FROM students GROUP BY grade;

d) HAVING: Filter records after grouping.

SELECT grade, COUNT(*) FROM students GROUP BY grade HAVING


COUNT(*) > 5;

5. SQL Functions
a) Aggregate Functions: Perform calculations on a set of values.

COUNT(): Counts the number of rows.


SUM(): Adds up values.
AVG(): Calculates the average.
MIN(): Finds the minimum value.
MAX(): Finds the maximum value.

sql code:------
SELECT COUNT(*) FROM students;
SELECT AVG(age) FROM students;

b) String Functions: Manipulate string data.

UPPER(): Converts to uppercase.


LOWER(): Converts to lowercase.
CONCAT(): Concatenates two or more strings.

sql code:---
SELECT UPPER(name) FROM students;
SELECT CONCAT(name, ' ', grade) FROM students;
c) Date Functions: Manipulate date values.

NOW(): Returns the current date and time.


CURDATE(): Returns the current date.

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.

============================================================ JQUERY JQUERY


CONCEPT
================================================================================
====

jQuery Introduction in PHP


What is jQuery?

* jQuery is a fast, small, and feature-rich JavaScript library. It simplifies


things like HTML document traversal and manipulation, event handling, and
animation.
* jQuery makes it easier to interact with the Document Object Model (DOM) and
can significantly reduce the amount of code needed to accomplish tasks compared
to plain JavaScript.

Why Use jQuery?


* Simplified Syntax: jQuery provides a concise syntax that allows developers to
accomplish complex tasks with less code.
* Cross-Browser Compatibility: jQuery handles many of the inconsistencies
between browsers, ensuring that your code works on all major browsers.
* Rich Set of Features: jQuery offers many built-in functions for DOM
manipulation, event handling, AJAX, animations, and effects.

Key Functionalities of jQuery:-----


1) DOM Manipulation:

* jQuery allows easy access to and manipulation of HTML elements.


* Example: Changing the text of a paragraph.
$(document).ready(function() {
$("p").text("New text using jQuery!");
});

2) Event Handling:

* jQuery simplifies event handling, such as clicks, form submissions, etc.


* Example: Handling a button click event.
$(document).ready(function() {
$("#myButton").click(function() {
alert("Button clicked!");
});
});
3) AJAX Support:

* 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);
}
});

4) Animations and Effects:

* jQuery includes methods for creating animations and visual effects.


* Example: Fading out an element.

$(document).ready(function() {
$("#myElement").fadeOut(1000); // Fades out over 1 second
});

5) CSS Manipulation:

* jQuery allows you to easily change CSS properties of elements.


* Example: Changing the background color of a div.
$("#myDiv").css("background-color", "blue");

6) Chaining:

* jQuery allows chaining of methods, making code more concise.


* Example:

$("#myDiv").css("color", "red").slideUp(2000).slideDown(2000);

#### Integrating jQuery with PHP


* jQuery can be used with PHP to enhance web applications. PHP can
handle server-side logic, while jQuery manages client-side interactivity.
* Example of using jQuery to submit a form and process it with PHP:

<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.

JQUERY EVENTS :======================================


1. Mouse Events
click: Triggered when an element is clicked.
dblclick: Triggered when an element is double-clicked.
mouseenter: Triggered when the mouse enters an element.
mouseleave: Triggered when the mouse leaves an element.
mousedown: Triggered when the mouse button is pressed down on an element.
mouseup: Triggered when the mouse button is released over an element.
mousemove: Triggered when the mouse moves over an element.
hover: Combines mouseenter and mouseleave in one function.

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

ready: Triggered when the DOM is fully loaded.


resize: Triggered when the window is resized.
scroll: Triggered when the window or an element with a scrollbar is scrolled.
unload: Triggered when the user leaves the page.
5. Focus Events
focusin: Similar to focus, but bubbles up (affects parent elements).
focusout: Similar to blur, but bubbles up.

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
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}}}}}}}}}}}}}}}}}}}}}]

यहाँ पर jQuery के कुछ मु कां से ् स आसान तरीके से समझाए गए ह:

1. jQuery ा है ?
* jQuery एक ी, ओपन-सोस JavaScript लाइ ेरी है ।
* इसका इ े माल HTML डॉ ूमट को आसानी से manipulate करने , इवट् स को हडल करने , और एनीमे शन बनाने के िलए होता
है ।
* इसका मु उ े JavaScript को आसान बनाना है ।

2. jQuery कोड कैसे िलखा जाता है ?


* jQuery कोड हमेशा $ िच से शु होता है । उदाहरण:
$(selector).action();
* यहाँ selector वह HTML एिलमट है िजस पर आप काम करना चाहते ह, और action() वह फ़ं न है जो आप उस
एिलमट पर अ ाई करगे ।

3. Selector ा होता है ?
* jQuery म Selector का उपयोग HTML एिलमट् स को िसले करने के िलए िकया जाता है ।
* उदाहरण:
* ID Selector: $("#myId") - इस से HTML एिलमट िसले होगा िजसका ID "myId" है ।
* Class Selector: $(".myClass") - इस से सभी एिलमट् स िसले होंगे िजनकी ास "myClass" है ।
* Tag Selector: $("p") - यह सभी <p> टै को िसले करे गा।

4. Event Handling (इवट हडिलंग)


* jQuery का एक मुख फीचर इवट् स को हडल करना है ।
* जैसे िक क, माउस ओवर, आिद।
* उदाहरण:
$("#myButton").click(function(){
alert("Button clicked!");
});

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);
}
});

7. Traversing (टै विसग)


* jQuery का उपयोग DOM म एक एिलमट से दू सरे एिलमट तक जाने के िलए िकया जाता है ।
* उदाहरण:
parent(), children(), siblings(), आिद।

8. DOM Manipulation
* jQuery के ारा HTML एिलमट् स को एड, रमूव, और चज िकया जा सकता है ।
* उदाहरण:
* HTML कंटट बदलना: $("#myDiv").html("नया कंटट");
* एिलमट जोड़ना: $("body").append("<p>नया पै रा ाफ</p>");
* ाइल बदलना: $("#myDiv").css("color", "red");

9. jQuery CDN से जोड़ना

* jQuery को अपनी वेबसाइट म जोड़ने के िलए CDN िलंक का उपयोग िकया जा सकता है ।
* उदाहरण:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
jQuery की मदद से आप आसानी से और तेज़ी से वेब पे ज म इं टरे व फीचस जोड़ सकते ह।

========================================================= AJAX CONCEPT


================================================================================
========
AJAX Concept in PHP
What is AJAX?

* AJAX (Asynchronous JavaScript and XML) is a technique used to create


asynchronous web applications. It allows web pages to update data without
requiring a full page reload.
* AJAX uses JavaScript to send and receive data from a server in the
background, providing a smoother and faster user experience.

Why Use AJAX?


* Improved User Experience: Users can interact with the web page without
interruptions, as data can be loaded in the background.
* Reduced Server Load: Only necessary data is sent to and from the server,
minimizing bandwidth usage.
* Faster Updates: Web applications can update parts of the page without
refreshing the entire page, leading to quicker interactions.

How AJAX Works with PHP


* Client-Side (JavaScript): JavaScript sends an AJAX request to the server.
* Server-Side (PHP): PHP processes the request, interacts with the database if
needed, and returns the response.
* Updating the Page: JavaScript receives the response and updates the web page
accordingly.
* Example: Simple AJAX with PHP
Step 1: Create the HTML Form

<!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>

Step 2: Create the PHP Script (process.php)

<?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.";
}
?>

* Explanation of the Example

* 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 ,
================================================================================
==

यहाँ AJAX के मु कां से ् स आसान तरीके से िहं दी म समझाए गए ह:

1. AJAX ा है ?
* AJAX का मतलब Asynchronous JavaScript and XML है ।
* यह एक तकनीक है िजससे वेब पे ज र े श िकए िबना ही सवर से डे टा भे जा और ा िकया जा सकता है ।
* इससे वेब ए केशन अिधक तेज और इं टरै व बनती है ।

2. AJAX कैसे काम करता है ?


* AJAX का काम करने का तरीका इस कार है :
1) वेब पे ज से एक इवट (जैसे बटन क) िटगर होता है ।
2) JavaScript XMLHttpRequest ऑ े का उपयोग करके सवर से एक र े भे जता है ।
3) सवर उस र े को ोसेस करता है और डे टा वापस भे जता है ।
4) JavaScript ारा डे टा ा िकया जाता है और वेब पे ज पर अपडे ट कर िदया जाता है िबना पे ज को रीलोड िकए।

3. AJAX के मु फायदे
* ीड: पे ज को बार-बार लोड नहीं करना पड़ता, इसिलए लोिडं ग का समय कम होता है ।
* बडिवड् थ की बचत: केवल आव क डे टा ही सवर से मंगाया जाता है ।
* यू ज़र ए पी रयंस: वेबसाइट अिधक इं टरै व और र ॉ व बनती है ।

4. AJAX म उपयोग होने वाले मु त


* XMLHttpRequest: यह एक ाउज़र ऑ े है िजसका उपयोग सवर से डे टा भे जने और ा करने के िलए होता है ।
* JavaScript: AJAX की सभी फं नैिलटी को कंटोल करता है ।
* सवर साइड ि ंग: जैसे PHP, ASP.NET आिद सवर पर डे टा ोसे स करने के िलए।

5. AJAX का िसंटै
* AJAX कॉल करने के िलए िसंपल जावा कोड इस तरह से िलखा जा सकता है :

var xhr = new XMLHttpRequest();


xhr.open("GET", "data.txt", true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
document.getElementById("myDiv").innerHTML = xhr.responseText;
}
};
xhr.send();

6. jQuery म AJAX का उपयोग


* jQuery म 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 एिलमट म डे टा लोड करने के िलए उपयोग होता है ।

8. AJAX ारा JSON डे टा लोड करना


* JSON फॉमट म डे टा को आसानी से ए चज िकया जा सकता है :

$.getJSON("data.json", function(data) {
$.each(data, function(key, value) {
$("#myDiv").append(key + ": " + value + "<br>");
});
});
* यहाँ , data.json से डे टा ा होता है और $.each() का उपयोग करके हर एक डे टा आइटम को वे ब पे ज पर जोड़ा जाता
है ।

9. AJAX Error Handling


* AJAX कॉल म एरर हडल करना मह पू ण होता है :

$.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_init() फं न का उपयोग कर एक cURL सेशन शु िकया जाता है ।


php
Copy code
$curl = curl_init();
Options सेट करना:

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_exec() फं न का उपयोग कर cURL र े को execute िकया जाता है और डे टा को ा िकया जाता है ।


php
Copy code
$response = curl_exec($curl);
Error Handling और Close करना:

अगर कोई एरर आती है तो 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 म फाइल हडिलंग का मतलब है िक हम फाइ को पढ़ सकते ह, िलख सकते ह, बना सकते ह, िडलीट कर सकते ह और एिडट
कर सकते ह। यह ब त उपयोगी होता है जब हम िकसी वेबसाइट पर डे टा को फाइ म ोर करना या उसे ए े स करना होता है ।
आसान भाषा म इसे समझते ह:

PHP म फाइल हडिलंग के बेिसक ऑपरे शंस


फाइल को ओपन करना (Open a File)

fopen() का उपयोग करके फाइल को ओपन िकया जाता है ।


इस फं न म फाइल का नाम और मोड (िकस तरह से फाइल खोलनी है ) पास करना होता है ।
Modes:
"r" : पढ़ने के िलए (Read-only)
"w" : िलखने के िलए (Write-only, फाइल पहले से मौजूद हो तो इसे ओवरराइट कर दे गा)
"a" : फाइल के अंत म िलखने के िलए (Append mode, पु राने डे टा को नही ं हटाता)
"r+" : पढ़ने और िलखने के िलए (Read/Write)
"w+" : फाइल को पढ़ने और िलखने के िलए (ओवरराइट करता है )
php
Copy code
$file = fopen("example.txt", "r");
फाइल पढ़ना (Read a File)

fread() फं न का उपयोग कर सकते ह। यह फाइल को पढ़ने के िलए होता है ।


fgets() का उपयोग करके फाइल की एक लाइन पढ़ी जा सकती है ।
php
Copy code
$content = fread($file, filesize("example.txt"));
echo $content;
फाइल म िलखना (Write to a File)

fwrite() का उपयोग करके फाइल म डे टा िलखा जाता है ।


अगर फाइल "w" मोड म है , तो पु राना डे टा ओवरराइट हो जाएगा। "a" मोड म डे टा जोड़ सकते ह।
php
Copy code
$file = fopen("example.txt", "w");
fwrite($file, "Hello, World!");
fclose($file);
फाइल को बंद करना (Close a File)

जब भी फाइल का उपयोग हो जाए, उसे fclose() से बं द कर दे ना चािहए तािक मेमोरी ी हो जाए।


php
Copy code
fclose($file);
फाइल को चेक करना (Checking File Exists)

file_exists() फं न का उपयोग करके चेक कर सकते ह िक फाइल मौजूद है या नहीं।


php
Copy code
if(file_exists("example.txt")) {
echo "File exists!";
} else {
echo "File does not exist.";
}
फाइल िडलीट करना (Delete a File)
unlink() फं न से फाइल को िडलीट कर सकते ह।
php
Copy code
if(unlink("example.txt")) {
echo "File deleted successfully.";
} else {
echo "File could not be deleted.";
}
Example Code: फाइल पढ़ने और िलखने का पू रा उदाहरण
php
Copy code
// फाइल को ओपन करना
$file = fopen("myfile.txt", "a");

// फाइल म डे टा िलखना
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 फाइल हडिलंग म फाइ को ओपन, रीड, राइट, और िडलीट करना शािमल है । यह िकसी भी कार के डे टा को फाइल म ोर
या ए े स करने म मदद करता है ।

=========================================== DOM CONCEPT


========================================================================
DOM (Document Object Model) Concepts in JavaScript
What is DOM?

* 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.

Key Concepts of DOM in JavaScript

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.

Common methods include:

a) getElementById(id): Selects an element by its ID.


) getElementsByClassName(className): Selects elements by their class name.
c) getElementsByTagName(tagName): Selects elements by their tag name.
d) querySelector(selector): Selects the first element that matches a CSS
selector.
e) querySelectorAll(selector): Selects all elements that match a CSS selector.

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:

// Create a new element


const newElement = document.createElement("p");
newElement.textContent = "This is a new paragraph.";

// Append the new element to the body


document.body.appendChild(newElement);

// 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!");
});

Traversing the DOM:

* You can navigate through the DOM tree using properties like parentNode,
childNodes, firstChild, lastChild, and nextSibling.
* Example:

const parent = element.parentNode; // Get the parent element


const children = parent.childNodes; // Get all child nodes

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 FRAMEWORK IN PHP :----

Laravel एक लोकि य PHP framework है जो web application development को सरल, तेज, और अिधक
संगिठत बनाता है । यहाँ Laravel के बारे म कुछ मह पू ण िबंदु िदए गए ह:

Laravel के मु िबंदु:
MVC आिकटे र:

Laravel Model-View-Controller (MVC) आिकटे र का पालन करता है , जो कोड को व त और


maintainable बनाता है ।
Model डे टा और business logic को संभालता है , View UI को िदखाता है , और Controller user input को
process करता है ।
Routing:

Laravel म routing ब त सरल है । आप आसानी से URL को controller methods से जोड़ सकते ह।


एक उदाहरण:
php
Copy code
Route::get('/welcome', 'WelcomeController@index');
Eloquent ORM:

Laravel म Eloquent Object-Relational Mapping (ORM) है , जो database interactions को


सरल बनाता है ।
यह database के records को model के प म उपयोग करने की अनु मित दे ता है ।
Migration:

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:

Middleware का उपयोग request और response को filter करने के िलए िकया जाता है । यह


authentication, logging, etc. जैसे tasks को संभालता है ।
उदाहरण:
php
Copy code
Route::get('/profile', function () {
// Only authenticated users may access this route
})->middleware('auth');
Security Features:
Laravel म CSRF protection, XSS protection, और SQL injection से सुर ा के िलए built-in
features ह।
यह security को ान म रखते ए िवकिसत िकया गया है ।
Artisan Console:

Laravel म Artisan एक command-line interface है , जो development tasks को automate करने


के िलए उपयोग िकया जाता है ।
आप नए controllers, models, migrations आिद बनाने के िलए Artisan commands का उपयोग कर सकते
ह।
Testing Support:

Laravel testing के िलए built-in support दान करता है । आप PHPUnit का उपयोग करके अपने
application के िलए automated tests िलख सकते ह।
Community and Ecosystem:

Laravel का एक बड़ा और सि य community है । इसके साथ ही कई packages और tools ह जो Laravel के


िवकास को और भी आसान बनाते ह, जैसे Laravel Forge, Laravel Nova, आिद।
Laravel का उपयोग कब कर?
जब आप एक बड़ा और complex web application बनाना चाहते ह।
जब आपको maintainable और scalable code की आव कता हो।
जब आपको security features और database management की आव कता हो।
िन ष
Laravel एक powerful और developer-friendly PHP framework है , जो web development को
आसान और तेज बनाता है । इसके features, tools, और community support इसे PHP developers के बीच
एक लोकि य िवक बनाते ह।

LARAVEL ARTISIAN COMMANDS


LIST:-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

ChatGPT
Laravel के Artisan commands ब त उपयोगी होते ह और ये web application development के िविभ
tasks को automate करने म मदद करते ह। यहाँ Laravel के कुछ मुख Artisan commands की सूची दी गई है :

Laravel Artisan Commands List


Application Commands:

php artisan help: िकसी भी Artisan command के िलए help दिशत करता है ।
php artisan list: सभी उपल Artisan commands की सूची िदखाता है ।
Environment Commands:

php artisan env: वतमान environment को िदखाता है ।


Database Commands:

php artisan migrate: सभी pending migrations को चलाता है ।


php artisan migrate:rollback: आ खरी migration को वापस ले जाता है ।
php artisan migrate:reset: सभी migrations को वापस ले जाता है ।
php artisan migrate:refresh: सभी migrations को वापस ले जाता है और िफर से चलाता है ।
php artisan migrate:fresh: database को खाली करता है और सभी migrations को िफर से चलाता है ।
php artisan db:seed: database म seeders को चलाता है ।
Model Commands:

php artisan make:model ModelName: एक नया model बनाता है ।


php artisan make:model ModelName -m: एक नया model और migration बनाता है ।
Controller Commands:

php artisan make:controller ControllerName: एक नया controller बनाता है ।


php artisan make:controller ControllerName --resource: एक resource controller
बनाता है ।
Migration Commands:

php artisan make:migration MigrationName: एक नई migration फाइल बनाता है ।


Seeder Commands:

php artisan make:seeder SeederName: एक नया seeder बनाता है ।


Factory Commands:

php artisan make:factory FactoryName: एक नया factory बनाता है ।


Event Commands:

php artisan make:event EventName: एक नया event बनाता है ।


php artisan make:listener ListenerName: एक नया listener बनाता है ।
Middleware Commands:

php artisan make:middleware MiddlewareName: एक नया middleware बनाता है ।


Test Commands:

php artisan make:test TestName: एक नया test class बनाता है ।


Cache Commands:

php artisan cache:clear: application cache को साफ करता है ।


php artisan config:cache: configuration को cache करता है ।
Queue Commands:

php artisan queue:work: queued jobs को process करता है ।


Route Commands:

php artisan route:list: सभी registered routes की सूची िदखाता है ।


Configuration Commands:

php artisan config:clear: configuration cache को साफ करता है ।


िन ष
Artisan commands Laravel development को तेज और आसान बनाते ह। आप अपने काम को आसान और
व त रखने के िलए इन commands का उपयोग कर सकते ह।

[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ JAVASCRIPT
CONCEPT
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
]]]]]]]]]]]]

JavaScript (JS) एक powerful programming language है जो primarily web development म


उपयोग होती है । यह client-side scripting के िलए सबसे ादा इ े माल की जाती है , ले िकन अब इसे
server-side development (Node.js) म भी इ े माल िकया जाता है । आइए JavaScript के कुछ मह पू ण
concepts को आसान िहं दी म समझते ह।

JavaScript के मह पू ण Concepts
1. JavaScript ा है ?
JavaScript एक scripting language है जो web pages को interactive और dynamic बनाने के िलए
उपयोग होती है ।
इसे Netscape ारा develop िकया गया था और अब यह एक standard है , िजसे ECMAScript कहा जाता है ।

2. JavaScript का उपयोग ों कर?


* Interactivity: Web pages पर interactivity जोड़ने के िलए (जैसे buttons, forms, आिद)।
* Dynamic Content: Page content को dynamically update करने के िलए।
* Client-side Validation: Form inputs की validation के िलए।
* Animations: Websites पर animations बनाने के िलए।

3. JavaScript Syntax (िसंटै )


* JavaScript म code िलखने के िलए िवशेष syntax का पालन िकया जाता है ।
* Code को statements म िलखा जाता है और statements को semicolon (;) से अलग िकया जाता है ।
* Example:
var name = "John"; // Variable declaration
console.log(name); // Output: John

4. Variables (वे रएब )


Variables का उपयोग data को store करने के िलए िकया जाता है ।
JavaScript म variables को declare करने के िलए var, let, और const keywords का उपयोग िकया
जाता है :
* var: पु राने तरीके से declare िकया गया variable, function-scoped।
* let: Block-scoped variable जो value को change िकया जा सकता है ।
* const: Block-scoped constant जो value को change नहीं िकया जा सकता।
Example:
var age = 25; // var
let city = "Delhi"; // let
const pi = 3.14; // const

5. Data Types (डे टा टाइ )


JavaScript म मु डे टा टाइ ह:
* String: टे , जैसे "Hello World"
* Number: सं ा, जैसे 42
* Boolean: सच या झूठ (true/false)
* Object: एक सं ह (collection) जैसे { name: "John", age: 30 }
* Array: डे टा का ordered collection जैसे [1, 2, 3, 4]
Example:
let str = "Hello"; // String
let num = 100; // Number
let isTrue = true; // Boolean
let obj = { name: "John", age: 30 }; // Object
let arr = [1, 2, 3, 4]; // Array

6. Operators (ऑपरे टस)


JavaScript म िविभ कार के operators होते ह:
* Arithmetic Operators: +, -, *, /, %
* Assignment Operators: =, +=, -=, *=, /=
* Comparison Operators: ==, ===, !=, !==, >, <, >=, <=
* Logical Operators: && (AND), || (OR), ! (NOT)
Example:
let sum = 10 + 20; // Addition
let isEqual = (5 == "5"); // true (loose equality)

7. Functions (फं ंस)


Functions को code के reusable blocks के प म define िकया जाता है ।
Function को declare करने के िलए function keyword का उपयोग िकया जाता है ।
Example:

function greet(name) {
return "Hello, " + name;
}
console.log(greet("John")); // Output: Hello, John

8. Conditional Statements (कंडीशनल े टमट् स)


Conditional statements का उपयोग decisions लेने के िलए िकया जाता है ।
मु conditional statements ह: if, else if, और else।
Example:
let age = 18;
if (age >= 18) {
console.log("You are an adult.");
} else {
console.log("You are a minor.");
}
9. Loops (लू )
Loops का उपयोग code के blocks को बार-बार execute करने के िलए िकया जाता है ।
मु loops ह: for, while, और do...while।
Example:

for (let i = 0; i < 5; i++) {


console.log("Count: " + i);
}

10. Events (इवट् स)


JavaScript events का उपयोग user actions (जैसे clicks, keyboard events) को handle करने
के िलए िकया जाता है ।
Example:

<button onclick="alert('Button Clicked!')">Click Me!</button>

11. DOM Manipulation (DOM मैिनपु लेशन)


Document Object Model (DOM) का उपयोग HTML elements को JavaScript से manipulate करने के
िलए िकया जाता है ।
Example:
document.getElementById("myElement").innerHTML = "New Content";
12. Arrays (एरे ज़)
Arrays का उपयोग एक से अिधक values को store करने के िलए िकया जाता है ।
Example:

let fruits = ["Apple", "Banana", "Cherry"];


console.log(fruits[0]); // Output: Apple

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 कर!

You might also like