Looking for a Tutor Near You?

Post Learning Requirement ยป
x

Choose Country Code

x

Direction

x

Ask a Question

x

Hire a Tutor

Introduction To PHP

Loading...

Published in: PHP And MySQL
953 Views

PHP stands for Hypertext Preprocessor. These notes give a slight introduction to PHP.

Neelam S / Ghaziabad

1 year of teaching experience

Qualification: B.Tech

Teaches: Basic Computer, MS Office, School Level Computer, Computer Science, IT & Computer Subjects, Chemistry, Mathematics, Social Studies, CSS Training, HTML Training, PHP And MySQL

Contact this Tutor
  1. Class 7 Strings: A string is a sequence of letters, numbers, special characters and arithmetic values or combination of all. The simplest way to create a string is to enclose the string literal (i.e. string characters) in single quotation marks ( ') or double quotation marks("). However, single and double quotation marks work in different ways. Strings enclosed in single-quotes are treated almost literally, whereas the strings delimited by the double quotes replaces variables with the string representations of their values as well as specially interpreting certain escape sequences. The escape-sequence replacements are: i. \n is replaced by the newline character ii. \r is replaced by the carriage-return character \t is replaced by the tab character 111. \$ is replaced by the dollar sign itself ($) iv. \" is replaced by a single double-quote (") v. vi. \\ is replaced by a single backslash (\) For example: < ?php $my_ str = 'World'; "Hello, $my_str! echo 'Hello, $my_str!'; echo echo echo ' echo '1\'11 be back'; Manipulation in String: Calculating the Length of a String: The strlen() function is used to calculate the number of characters inside a string. It also includes the blank spaces inside the string.
  2. For example: < ?php $my_str = 'Welcome to Tutorial Republic'; echo strlen($my_str); Counting Number of Words in a String: The str_word_count() function counts the number of words in a string. For example: < ?php $my_str = 'The quick brown fox jumps over the lazy dog.', echo str_word_count($my_str); Replacing Text within Strings: The str_replace() replaces all occurrences of the search text within the target string. For example: < ?php $my_str = 'If the facts do not fit the theory, change the facts.'; echo str_replace("facts", "truth", $my_str); Reversing a String: The strrev() function reverses a string. For example: < ?php $my_str = 'You can do anything, but not everything. '; echo strrev($my_str); Search For a Specific Text Within a String: The strpos() function is used to search for a string or character within a string. For example: < ?php $string = "This is a strpos() test"; print strpos($string, "strpos") . "\n"