php tutorial - PHP substr Function - php programming - learn php - php code - php script

  • The substr function is used for returning the part of string.

php scripts Syntax :

click below button to copy the code. php tutorial - team

  • The substr string function contains three basic parameters. The first parameter of the string defines original string content.
  • Second parameter is defining the position of the starting point.
  • Third parameter is the number of characters to be returned.

Sample Code in php : sample php program

<!DOCTYPE html>
            $var1 = 'Welcome to wikitechy technical forum';
            echo substr($var1,0,20).'...';
click below button to copy the code. php tutorial - team

php programmer Code Explanation :

Code Explanation for substr Function In PHP

  1. In this example the “$var1” contains a set of character (or) string.
  2. In this echo statement we call the substr string function that contains three parameters: the first parameter($var1) defines given string and the second parameter (0) as the starting positon of the string and the third parameter (20) as end of string position.

php development Sample Output :

output for substr Function In PHP

  1. Output is “Welcome to wikitechy technical forum” will be sub stringed using substr function where the string function has the initial value as “0” and end position of the string as “20” , so that content ( Welcome to wikitechy) will only be displayed in this output window as shown.

Related Searches to php substr function

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add to your ad blocking whitelist or disable your adblocking software.