This chapter discusses working with text and numbers in PHP. It covers defining and manipulating strings, including validating, formatting, and changing case. Functions for selecting, replacing, and exploding parts of strings are described. Working with numbers, math operators, variables, and number formatting functions are also summarized. Key string functions include substr(), str_replace(), printf(), and number functions include rand(), round(), pow(), and abs().
String handling and arrays by Dr.C.R.Dhivyaa Kongu Engineering CollegeDhivyaa C.R
This document discusses strings and arrays in PHP. It covers:
- Defining strings using quotes, concatenation, and heredoc syntax
- Common string functions like length, position, comparison, replacement
- Creating arrays using assignment, array() constructor, and functions
- Retrieving array values by index and with list()
- Multidimensional arrays containing other arrays
- The document provides examples of each PHP string and array concept.
This document discusses strings and arrays in PHP. It covers string functions like strlen(), strpos(), and substr() for inspecting, comparing, and manipulating strings. It also covers creating, accessing, and iterating through arrays, including multidimensional arrays. Functions like count(), current(), next(), reset(), and foreach are described for working with arrays. The document also introduces numerical types in PHP like integers and floats.
Tokens in php (php: Hypertext Preprocessor).pptxBINJAD1
In PHP a token is considered an individual component of a program. The keywords, variables, constants, operators and strings used in a program are tokens in PHP.
The document discusses strings in C including how to declare, initialize, input, output, and manipulate strings using standard library functions as well as how to manage arrays of strings. It provides examples of declaring and initializing strings, using scanf and gets to input strings, common string manipulation functions like strlen and strcpy, and demonstrates how to work with arrays of strings such as storing and sorting a list of names.
This document contains notes from a Python class covering functions, lists, strings, and their methods. It discusses built-in functions like len(), range(), and type conversions. It also covers control flow structures like if/else, for loops, exceptions, modules, and functions in more detail including defining functions, parameters, arguments, returning values, docstring, and variable scopes. Assignments include writing functions to process lists and check for palindromes in strings.
This document discusses text and numbers in programming. It covers defining and manipulating text strings using single or double quotes. Escape characters can be used inside strings. Text can be validated and formatted using various string functions like trim(), strlen(), strtoupper(), substr(), and str_replace(). Numbers can be integers or floats. Variables hold data and can be operated on with arithmetic and assignment operators like +, -, *, /, %, and .=. Variables can also be incremented, decremented, and placed inside strings.
This chapter discusses string manipulation functions in PHP. It covers constructing strings, working with single strings through functions like strlen() and strtoupper(), working with multiple strings by parsing and splitting them with functions like explode() and strtok(), comparing strings, and using regular expressions. The chapter provides examples of encoding/decoding strings and manipulating case, as well as counting characters, words, and searching/extracting substrings.
The document discusses strings in C programming. It defines strings as arrays of characters terminated by a null character. It explains that string handling functions are declared in the string.h header file and are used to perform operations on strings like getting the length, concatenating, comparing, and manipulating case. Several functions are described like strlen(), strcpy(), strcat(), strcmp(), strrev(), strlwr(), strupr(). Examples are given showing how to use these functions to work with strings.
This document provides an introduction to server-side scripting and PHP. It discusses how server-side pages work by having the web server run scripts and send HTML to users' browsers. It then lists several common server-side scripting languages like PHP, ASP, and Python. The document proceeds to introduce PHP in more detail, covering its basics like syntax, variables, strings, arithmetic operators, and functions. It provides examples of conditional statements like if/else and looping with for and while loops.
This document provides an outline and overview of functions for handling characters and strings in C from several standard libraries. It discusses fundamentals of characters and strings, the character handling library ctype.h, string conversion functions in stdlib.h, I/O functions in stdio.h, and string processing functions in string.h, including searching, comparing, tokenizing and memory functions. The goal is to introduce techniques for text processing using these standard libraries.
This document provides an overview of strings and regular expressions in Python. It discusses string comparison, formatting, slicing, splitting, and stripping. For regular expressions, it covers matching, search and replace, and patterns. Meta characters, special sequences, sets, search, and common patterns are explained.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then gives the code to the processor to execute. Functions allow code to be reused by defining operations and optionally returning values. Strings are sequences of characters that can be manipulated using indexes and methods. Common string methods include upper() and concatenation using +.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then gives the code to the processor to execute. Functions allow code to be reused by defining operations and returning values. Strings are sequences of characters that can be manipulated using indexes and methods. Common string methods include upper() and concatenation using +.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then tells the processor to execute the program. Functions allow code to be reused by defining operations that take in arguments and return values. Strings are sequences of characters that can be accessed by index and manipulated with methods like upper() that return new strings.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then gives the code to the processor to execute. Functions allow code to be reused by defining operations and returning values. Strings are sequences of characters that can be manipulated using indexes and methods. Common string methods include upper() and concatenation using +.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then gives the code to the processor to execute. Functions allow code to be reused by defining operations and returning values. Strings are sequences of characters that can be accessed by index and manipulated with methods like upper() that return new strings.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then gives the code to the processor to execute. Functions allow code to be reused by defining operations and returning values. Strings are sequences of characters that can be accessed by index and manipulated with methods like upper() that return new strings.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then gives the code to the processor to execute. Functions allow code to be reused by defining operations and returning values. Strings are sequences of characters that can be manipulated using indexes and methods. Common string methods include upper() and concatenation using +.
This document discusses PHP functions including:
- The syntax and advantages of functions
- Common string, numeric, and date/time functions
- Creating user-defined functions
- Passing arguments to functions
- Returning values from functions
The document provides examples of using built-in PHP functions like strlen(), rand(), date(), and creating user-defined functions that can accept arguments and return values. It also discusses concepts like default arguments and stopping function execution with return.
The document discusses pointers in C programming. It defines a pointer as a variable that stores the memory address of another variable rather than the actual data. Pointers can be used to return multiple values from a function, pass arrays and strings to functions, and dynamically allocate and access memory. The key pointer operators are the address of (&) operator, which returns the address of its operand, and the dereferencing (*) operator, which refers to the object a pointer points to. Pointers can be passed to functions by value or by reference. The document also discusses structures, which allow grouping of different data types, and arrays, which can be passed to functions where only the array address is passed.
To define responsive web design means that your website (and its pages) can adapt and deliver the best experience to users, whether they’re on their desktop, laptop, tablet, or smartphone. For that to happen, though, your website needs a responsive design.
Ad
More Related Content
Similar to strings in php how to use different data types in string (20)
This chapter discusses string manipulation functions in PHP. It covers constructing strings, working with single strings through functions like strlen() and strtoupper(), working with multiple strings by parsing and splitting them with functions like explode() and strtok(), comparing strings, and using regular expressions. The chapter provides examples of encoding/decoding strings and manipulating case, as well as counting characters, words, and searching/extracting substrings.
The document discusses strings in C programming. It defines strings as arrays of characters terminated by a null character. It explains that string handling functions are declared in the string.h header file and are used to perform operations on strings like getting the length, concatenating, comparing, and manipulating case. Several functions are described like strlen(), strcpy(), strcat(), strcmp(), strrev(), strlwr(), strupr(). Examples are given showing how to use these functions to work with strings.
This document provides an introduction to server-side scripting and PHP. It discusses how server-side pages work by having the web server run scripts and send HTML to users' browsers. It then lists several common server-side scripting languages like PHP, ASP, and Python. The document proceeds to introduce PHP in more detail, covering its basics like syntax, variables, strings, arithmetic operators, and functions. It provides examples of conditional statements like if/else and looping with for and while loops.
This document provides an outline and overview of functions for handling characters and strings in C from several standard libraries. It discusses fundamentals of characters and strings, the character handling library ctype.h, string conversion functions in stdlib.h, I/O functions in stdio.h, and string processing functions in string.h, including searching, comparing, tokenizing and memory functions. The goal is to introduce techniques for text processing using these standard libraries.
This document provides an overview of strings and regular expressions in Python. It discusses string comparison, formatting, slicing, splitting, and stripping. For regular expressions, it covers matching, search and replace, and patterns. Meta characters, special sequences, sets, search, and common patterns are explained.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then gives the code to the processor to execute. Functions allow code to be reused by defining operations and optionally returning values. Strings are sequences of characters that can be manipulated using indexes and methods. Common string methods include upper() and concatenation using +.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then gives the code to the processor to execute. Functions allow code to be reused by defining operations and returning values. Strings are sequences of characters that can be manipulated using indexes and methods. Common string methods include upper() and concatenation using +.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then tells the processor to execute the program. Functions allow code to be reused by defining operations that take in arguments and return values. Strings are sequences of characters that can be accessed by index and manipulated with methods like upper() that return new strings.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then gives the code to the processor to execute. Functions allow code to be reused by defining operations and returning values. Strings are sequences of characters that can be manipulated using indexes and methods. Common string methods include upper() and concatenation using +.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then gives the code to the processor to execute. Functions allow code to be reused by defining operations and returning values. Strings are sequences of characters that can be accessed by index and manipulated with methods like upper() that return new strings.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then gives the code to the processor to execute. Functions allow code to be reused by defining operations and returning values. Strings are sequences of characters that can be accessed by index and manipulated with methods like upper() that return new strings.
A program is a sequence of instructions that are run by the processor. To run a program, it must be compiled into binary code and given to the operating system. The OS then gives the code to the processor to execute. Functions allow code to be reused by defining operations and returning values. Strings are sequences of characters that can be manipulated using indexes and methods. Common string methods include upper() and concatenation using +.
This document discusses PHP functions including:
- The syntax and advantages of functions
- Common string, numeric, and date/time functions
- Creating user-defined functions
- Passing arguments to functions
- Returning values from functions
The document provides examples of using built-in PHP functions like strlen(), rand(), date(), and creating user-defined functions that can accept arguments and return values. It also discusses concepts like default arguments and stopping function execution with return.
The document discusses pointers in C programming. It defines a pointer as a variable that stores the memory address of another variable rather than the actual data. Pointers can be used to return multiple values from a function, pass arrays and strings to functions, and dynamically allocate and access memory. The key pointer operators are the address of (&) operator, which returns the address of its operand, and the dereferencing (*) operator, which refers to the object a pointer points to. Pointers can be passed to functions by value or by reference. The document also discusses structures, which allow grouping of different data types, and arrays, which can be passed to functions where only the array address is passed.
To define responsive web design means that your website (and its pages) can adapt and deliver the best experience to users, whether they’re on their desktop, laptop, tablet, or smartphone. For that to happen, though, your website needs a responsive design.
software evelopment life cycle model and example of water fall modelvishal choudhary
studying the existing or obsolete system and software,
conducting interviews of users and developers,
referring to the database or
collecting answers from the questionnaires.
software Engineering lecture on development life cyclevishal choudhary
SDLC starts from the moment, when it’s made a decision to launch the project.
There is no one single SDLC model.
They are divided into groups,
Each with its features and weaknesses
The document provides an introduction to software engineering. It defines software engineering as an engineering discipline concerned with all aspects of software production. It discusses why software engineering is important given that errors in complex software systems can have devastating consequences, as shown through examples of software failures in air traffic control, satellite launches, and ambulance dispatch systems. The document also covers fundamental software engineering concepts like the software process, process models, and costs.
The document discusses software testing concepts like validation testing vs defect testing, system and component testing strategies, and test automation tools. It defines key terms like bugs, defects, errors, faults, and failures. It also describes techniques like equivalence partitioning and boundary value analysis that are used to generate test cases that thoroughly test software. Component testing tests individual program parts while system testing tests integrated groups of components. Test cases specify conditions to determine if software works as intended.
A measles outbreak originating in West Texas has been linked to confirmed cases in New Mexico, with additional cases reported in Oklahoma and Kansas. The current case count is 795 from Texas, New Mexico, Oklahoma, and Kansas. 95 individuals have required hospitalization, and 3 deaths, 2 children in Texas and one adult in New Mexico. These fatalities mark the first measles-related deaths in the United States since 2015 and the first pediatric measles death since 2003.
The YSPH Virtual Medical Operations Center Briefs (VMOC) were created as a service-learning project by faculty and graduate students at the Yale School of Public Health in response to the 2010 Haiti Earthquake. Each year, the VMOC Briefs are produced by students enrolled in Environmental Health Science Course 581 - Public Health Emergencies: Disaster Planning and Response. These briefs compile diverse information sources – including status reports, maps, news articles, and web content– into a single, easily digestible document that can be widely shared and used interactively. Key features of this report include:
- Comprehensive Overview: Provides situation updates, maps, relevant news, and web resources.
- Accessibility: Designed for easy reading, wide distribution, and interactive use.
- Collaboration: The “unlocked" format enables other responders to share, copy, and adapt seamlessly. The students learn by doing, quickly discovering how and where to find critical information and presenting it in an easily understood manner.
Title: A Quick and Illustrated Guide to APA Style Referencing (7th Edition)
This visual and beginner-friendly guide simplifies the APA referencing style (7th edition) for academic writing. Designed especially for commerce students and research beginners, it includes:
✅ Real examples from original research papers
✅ Color-coded diagrams for clarity
✅ Key rules for in-text citation and reference list formatting
✅ Free citation tools like Mendeley & Zotero explained
Whether you're writing a college assignment, dissertation, or academic article, this guide will help you cite your sources correctly, confidently, and consistent.
Created by: Prof. Ishika Ghosh,
Faculty.
📩 For queries or feedback: [email protected]
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...larencebapu132
This is short and accurate description of World war-1 (1914-18)
It can give you the perfect factual conceptual clarity on the great war
Regards Simanchala Sarab
Student of BABed(ITEP, Secondary stage)in History at Guru Nanak Dev University Amritsar Punjab 🙏🙏
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...Celine George
Analytic accounts are used to track and manage financial transactions related to specific projects, departments, or business units. They provide detailed insights into costs and revenues at a granular level, independent of the main accounting system. This helps to better understand profitability, performance, and resource allocation, making it easier to make informed financial decisions and strategic planning.
The Pala kings were people-protectors. In fact, Gopal was elected to the throne only to end Matsya Nyaya. Bhagalpur Abhiledh states that Dharmapala imposed only fair taxes on the people. Rampala abolished the unjust taxes imposed by Bhima. The Pala rulers were lovers of learning. Vikramshila University was established by Dharmapala. He opened 50 other learning centers. A famous Buddhist scholar named Haribhadra was to be present in his court. Devpala appointed another Buddhist scholar named Veerdeva as the vice president of Nalanda Vihar. Among other scholars of this period, Sandhyakar Nandi, Chakrapani Dutta and Vajradatta are especially famous. Sandhyakar Nandi wrote the famous poem of this period 'Ramcharit'.
How to Set warnings for invoicing specific customers in odooCeline George
Odoo 16 offers a powerful platform for managing sales documents and invoicing efficiently. One of its standout features is the ability to set warnings and block messages for specific customers during the invoicing process.
GDGLSPGCOER - Git and GitHub Workshop.pptxazeenhodekar
This presentation covers the fundamentals of Git and version control in a practical, beginner-friendly way. Learn key commands, the Git data model, commit workflows, and how to collaborate effectively using Git — all explained with visuals, examples, and relatable humor.
A measles outbreak originating in West Texas has been linked to confirmed cases in New Mexico, with additional cases reported in Oklahoma and Kansas. The current case count is 817 from Texas, New Mexico, Oklahoma, and Kansas. 97 individuals have required hospitalization, and 3 deaths, 2 children in Texas and one adult in New Mexico. These fatalities mark the first measles-related deaths in the United States since 2015 and the first pediatric measles death since 2003.
The YSPH Virtual Medical Operations Center Briefs (VMOC) were created as a service-learning project by faculty and graduate students at the Yale School of Public Health in response to the 2010 Haiti Earthquake. Each year, the VMOC Briefs are produced by students enrolled in Environmental Health Science Course 581 - Public Health Emergencies: Disaster Planning and Response. These briefs compile diverse information sources – including status reports, maps, news articles, and web content– into a single, easily digestible document that can be widely shared and used interactively. Key features of this report include:
- Comprehensive Overview: Provides situation updates, maps, relevant news, and web resources.
- Accessibility: Designed for easy reading, wide distribution, and interactive use.
- Collaboration: The “unlocked" format enables other responders to share, copy, and adapt seamlessly. The students learn by doing, quickly discovering how and where to find critical information and presenting it in an easily understood manner.
CURRENT CASE COUNT: 817 (As of 05/3/2025)
• Texas: 688 (+20)(62% of these cases are in Gaines County).
• New Mexico: 67 (+1 )(92.4% of the cases are from Eddy County)
• Oklahoma: 16 (+1)
• Kansas: 46 (32% of the cases are from Gray County)
HOSPITALIZATIONS: 97 (+2)
• Texas: 89 (+2) - This is 13.02% of all TX cases.
• New Mexico: 7 - This is 10.6% of all NM cases.
• Kansas: 1 - This is 2.7% of all KS cases.
DEATHS: 3
• Texas: 2 – This is 0.31% of all cases
• New Mexico: 1 – This is 1.54% of all cases
US NATIONAL CASE COUNT: 967 (Confirmed and suspected):
INTERNATIONAL SPREAD (As of 4/2/2025)
• Mexico – 865 (+58)
‒Chihuahua, Mexico: 844 (+58) cases, 3 hospitalizations, 1 fatality
• Canada: 1531 (+270) (This reflects Ontario's Outbreak, which began 11/24)
‒Ontario, Canada – 1243 (+223) cases, 84 hospitalizations.
• Europe: 6,814
This chapter provides an in-depth overview of the viscosity of macromolecules, an essential concept in biophysics and medical sciences, especially in understanding fluid behavior like blood flow in the human body.
Key concepts covered include:
✅ Definition and Types of Viscosity: Dynamic vs. Kinematic viscosity, cohesion, and adhesion.
⚙️ Methods of Measuring Viscosity:
Rotary Viscometer
Vibrational Viscometer
Falling Object Method
Capillary Viscometer
🌡️ Factors Affecting Viscosity: Temperature, composition, flow rate.
🩺 Clinical Relevance: Impact of blood viscosity in cardiovascular health.
🌊 Fluid Dynamics: Laminar vs. turbulent flow, Reynolds number.
🔬 Extension Techniques:
Chromatography (adsorption, partition, TLC, etc.)
Electrophoresis (protein/DNA separation)
Sedimentation and Centrifugation methods.
Exploring Substances:
Acidic, Basic, and
Neutral
Welcome to the fascinating world of acids and bases! Join siblings Ashwin and
Keerthi as they explore the colorful world of substances at their school's
National Science Day fair. Their adventure begins with a mysterious white paper
that reveals hidden messages when sprayed with a special liquid.
In this presentation, we'll discover how different substances can be classified as
acidic, basic, or neutral. We'll explore natural indicators like litmus, red rose
extract, and turmeric that help us identify these substances through color
changes. We'll also learn about neutralization reactions and their applications in
our daily lives.
by sandeep swamy
The *nervous system of insects* is a complex network of nerve cells (neurons) and supporting cells that process and transmit information. Here's an overview:
Structure
1. *Brain*: The insect brain is a complex structure that processes sensory information, controls behavior, and integrates information.
2. *Ventral nerve cord*: A chain of ganglia (nerve clusters) that runs along the insect's body, controlling movement and sensory processing.
3. *Peripheral nervous system*: Nerves that connect the central nervous system to sensory organs and muscles.
Functions
1. *Sensory processing*: Insects can detect and respond to various stimuli, such as light, sound, touch, taste, and smell.
2. *Motor control*: The nervous system controls movement, including walking, flying, and feeding.
3. *Behavioral responThe *nervous system of insects* is a complex network of nerve cells (neurons) and supporting cells that process and transmit information. Here's an overview:
Structure
1. *Brain*: The insect brain is a complex structure that processes sensory information, controls behavior, and integrates information.
2. *Ventral nerve cord*: A chain of ganglia (nerve clusters) that runs along the insect's body, controlling movement and sensory processing.
3. *Peripheral nervous system*: Nerves that connect the central nervous system to sensory organs and muscles.
Functions
1. *Sensory processing*: Insects can detect and respond to various stimuli, such as light, sound, touch, taste, and smell.
2. *Motor control*: The nervous system controls movement, including walking, flying, and feeding.
3. *Behavioral responses*: Insects can exhibit complex behaviors, such as mating, foraging, and social interactions.
Characteristics
1. *Decentralized*: Insect nervous systems have some autonomy in different body parts.
2. *Specialized*: Different parts of the nervous system are specialized for specific functions.
3. *Efficient*: Insect nervous systems are highly efficient, allowing for rapid processing and response to stimuli.
The insect nervous system is a remarkable example of evolutionary adaptation, enabling insects to thrive in diverse environments.
The insect nervous system is a remarkable example of evolutionary adaptation, enabling insects to thrive
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schoolsdogden2
Algebra 1 is often described as a “gateway” class, a pivotal moment that can shape the rest of a student’s K–12 education. Early access is key: successfully completing Algebra 1 in middle school allows students to complete advanced math and science coursework in high school, which research shows lead to higher wages and lower rates of unemployment in adulthood.
Learn how The Atlanta Public Schools is using their data to create a more equitable enrollment in middle school Algebra classes.
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsDrNidhiAgarwal
Unemployment is a major social problem, by which not only rural population have suffered but also urban population are suffered while they are literate having good qualification.The evil consequences like poverty, frustration, revolution
result in crimes and social disorganization. Therefore, it is
necessary that all efforts be made to have maximum.
employment facilities. The Government of India has already
announced that the question of payment of unemployment
allowance cannot be considered in India
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetSritoma Majumder
Introduction
All the materials around us are made up of elements. These elements can be broadly divided into two major groups:
Metals
Non-Metals
Each group has its own unique physical and chemical properties. Let's understand them one by one.
Physical Properties
1. Appearance
Metals: Shiny (lustrous). Example: gold, silver, copper.
Non-metals: Dull appearance (except iodine, which is shiny).
2. Hardness
Metals: Generally hard. Example: iron.
Non-metals: Usually soft (except diamond, a form of carbon, which is very hard).
3. State
Metals: Mostly solids at room temperature (except mercury, which is a liquid).
Non-metals: Can be solids, liquids, or gases. Example: oxygen (gas), bromine (liquid), sulphur (solid).
4. Malleability
Metals: Can be hammered into thin sheets (malleable).
Non-metals: Not malleable. They break when hammered (brittle).
5. Ductility
Metals: Can be drawn into wires (ductile).
Non-metals: Not ductile.
6. Conductivity
Metals: Good conductors of heat and electricity.
Non-metals: Poor conductors (except graphite, which is a good conductor).
7. Sonorous Nature
Metals: Produce a ringing sound when struck.
Non-metals: Do not produce sound.
Chemical Properties
1. Reaction with Oxygen
Metals react with oxygen to form metal oxides.
These metal oxides are usually basic.
Non-metals react with oxygen to form non-metallic oxides.
These oxides are usually acidic.
2. Reaction with Water
Metals:
Some react vigorously (e.g., sodium).
Some react slowly (e.g., iron).
Some do not react at all (e.g., gold, silver).
Non-metals: Generally do not react with water.
3. Reaction with Acids
Metals react with acids to produce salt and hydrogen gas.
Non-metals: Do not react with acids.
4. Reaction with Bases
Some non-metals react with bases to form salts, but this is rare.
Metals generally do not react with bases directly (except amphoteric metals like aluminum and zinc).
Displacement Reaction
More reactive metals can displace less reactive metals from their salt solutions.
Uses of Metals
Iron: Making machines, tools, and buildings.
Aluminum: Used in aircraft, utensils.
Copper: Electrical wires.
Gold and Silver: Jewelry.
Zinc: Coating iron to prevent rusting (galvanization).
Uses of Non-Metals
Oxygen: Breathing.
Nitrogen: Fertilizers.
Chlorine: Water purification.
Carbon: Fuel (coal), steel-making (coke).
Iodine: Medicines.
Alloys
An alloy is a mixture of metals or a metal with a non-metal.
Alloys have improved properties like strength, resistance to rusting.
4. Single Quoted
• The simplest way to create a string is to enclose the string literal (i.e.
string characters) in single quotation marks ('), like this:
5. Double-quote strings
• Unlike single-quote strings, double-quote strings in PHP are capable
of processing special characters.
9. We can perform several functions on string in PHP . The string manipulation functions are.
10. PHP Strings
A string is a sequence of characters, like "Hello world!".
we will look at some commonly used functions to manipulate strings.
strlen() - Return the Length of a String
The PHP strlen() function returns the length of a string.
11. str_word_count() - Count Words in a String
The PHP str_word_count() function counts the number of words in a string.
12. strrev() - Reverse a String
The PHP strrev() function reverses a string.
13. trim() function:
• This function allows us to remove whitespaces or strings from both
sides of a string.
15. str_replace() - Replace Text Within a String
The PHP str_replace() function replaces some characters with some other characters in a string.
21. Cleaning Strings
The trim() function removes whitespace and other predefined characters from both sides
of a string.
Related functions:
•ltrim() - Removes whitespace or other predefined characters from the left side of a
string
•rtrim() - Removes whitespace or other predefined characters from the right side of a
string
24. chop() Function
• The chop() function is used to remove whitespace or other predefined
character from the right end of a string.
• Syntax: chop(string,charlist);
• Example
<?php
$str = "Hello World!";
echo "Your string is :".$str."<br>";
echo "By using 'chop()' Functions is your string is: ".chop($str,"World!");
?>
Parameter Description Required/Optional
string the string to be
check
Required
charlist charlist parameter
is empty
Optional
Output:
Your string is :Hello
World!
By using 'chop()'
Functions is your
string is: Hello
25. PHP chunk_split() Function
• PHP chunk_split() function is used to splits a string into smaller parts
or chunks. The function does not alter the original string.
• Syntax: chunk_split(string,length,end)
<?php
$str = "Hello!;
echo "Your string is:".$str;
echo "By using 'chunk_split()' function your string is:".chunk_split($str,1,".
..");
?>
Parameter Description Required/Optional
string String to split Required
Length Specify the length of the
chunks. Default is 76
Optional
end Specify what to place at
the end each chunk.
Optional
Output:
Your string is: Hello
By using 'chunk_split()' function your string
is: H…e...l...l...o...!...
26. PHP type casting
• Type casting allows you to convert a value of one type to another.
To cast a value, you use the following type casting operators:
27. Which of the following functions is used to find
the first occurrence of a substring in a string?
• strlen()
• strpos()
• str_replace()
• str_split()
28. Which of the following functions is used to find
the first occurrence of a substring in a string?
• strlen()
• strpos()
• str_replace()
• str_split()
29. Which of the following functions is used to replace all
occurrences of a substring in a string with another substring?
• strlen()
• strpos()
• str_replace()
• str_split()
30. Which of the following functions is used to replace all
occurrences of a substring in a string with another substring?
• strlen()
• strpos()
• str_replace()
• str_split()
31. Which of the following functions is used to
count the number of words in a string?
• strlen()
• strpos()
• str_replace()
• str_word_count()
32. Which of the following functions is used to
count the number of words in a string?
• strlen()
• strpos()
• str_replace()
• str_word_count()
33. Which of the following is not a built-in PHP
function for working with strings?
• strlen()
• strpos()
• str_replace()
• str_split()
• strrev()
34. Which of the following is not a built-in PHP
function for working with strings?
• strlen()
• strpos()
• str_replace()
• str_split()
• strrev()
35. What is the following is the output of the following PHP code?
•
• $str = "Hello, world!";
• echo strlen($str);
• 13
36. What is the following is the output of the following PHP code?
• <?php
• $str = "Hello, world!";
• echo strpos($str, "world");
• ?>
• 7
37. What is the following is the output of the following PHP code?
• <?php
• $str = "Hello, world!";
• echo str_replace("world", "universe", $str);
• ?>
• Hello universe
38. What is the following is the output of the following PHP code?
• <?php
• $str = "Hello, world!";
• echo $str[0];
• ?>
• H