LearnPick Navigation
Close

Introduction To PHP

Published in: PHP and MySQL
357 views
  • Neelam S

    • Ghaziabad
    • 1 Years of Experience
    • Qualification: B.Tech
    • Teaches: School level computer, Mathematics, Computer Scien...
  • Contact this tutor

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

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

Discussion

Copyright Infringement: All the contents displayed here are being uploaded by our members. If an user uploaded your copyrighted material to LearnPick without your permission, please submit a Takedown Request for removal.

Need a Tutor or Coaching Class?

Post an enquiry and get instant responses from qualified and experienced tutors.

Post Requirement

Related Notes

Query submitted.

Thank you!

Drop Us a Query:

Drop Us a Query