How to Show the First Part of the Paragraph in PHP

How to Show the First Part of the Paragraph in PHP thumbnail
The PHP language provides many string conversion options.

The PHP programming language enables you to create dynamic Web pages with variable content, such as parsed data. Display the first part of a given paragraph using the PHP Substr method, which returns a section of a string according to the parameter values specified.

Instructions

    • 1

      Create the PHP file inside a text, PHP or HTML editor.

    • 2

      Type the following code:

      <?php
      $para = "SOME WORDS IN A PARAGRAPH";
      $newpara = substr($mytext, 0, 4);
      // outputs “SOME”
      echo $newpara;
      ?>

      The Substr method receives three parameters: the string, the start position and the length. This example starts at the first position and outputs four characters.

    • 3

      Upload the PHP file to your server. Test the page by opening it in a Web browser.

Related Searches:

Resources

  • Photo Credit Jupiterimages/BananaStock/Getty Images

Comments

Related Ads

Featured