String Functions in PHP: Part 12

Introduction

In this article I describe the PHP string functions print, printf and quoted_printable_decode. To learn some other math functions, go to:

  1. String Functions in PHP: Part1
     
  2. String Functions in PHP:Part2
     
  3. String Functions in PHP:Part3
     
  4. String Functions in PHP:Part4
     
  5. String Functions in PHP:Part5
     
  6. String Functions in PHP:Part6
     
  7. String Functions in PHP:Part7
     
  8. String Functions in PHP:Part8
     
  9. String Functions in PHP:Part9
     
  10. String Functions in PHP:Part10
     
  11. String Functions in PHP:Part11

PHP print() function

The PHP string print() function displays the output in the browser or outputs one or more strings.

Syntax

print(strings)

Parameter in print function

The parameter of the print function is:

Parameter Description
strings It specifies the input data.

Example

An example of the print
function is: 

<?php

print "Welcome";

$str=" at MCN Solution";

print $str;

?>

Output

print-string-function-in-php.gif

PHP printf() function

The PHP string printf() function outputs a formatted string.

Syntax
 

printf(format.arg1,arg2,..............)

Parameter in printf function

The parameters of the printf function are:

Parameter Description
format It specifies the string and specifies how to format the variables in it.
arg1 It specifies the argument.
arg2 It also specifies another argument.

Example

An example of the printf
function is: 

<?php

$var = "MCN";

$number = 1;

printf("%s Solution. Rank no %u",$var,$number);

?>

Output

printf-string-function-in-php.gif

PHP quoted_printable_decode() function

The PHP string quoted_printable_decode() function convert a quoted-printable string to an 8 bit string.

Syntax

quoted_printable_decode(string)

Parameter in quoted_printable_decode function

The parameters of the quoted_printable_decode function is:

Parameter Description
strings It specifies the quoted-printable string to decode.

Example

An example of the
quoted_printable_decode function is: 

<?php

$str = "MCN=0ASolution.";

echo quoted_printable_decode($str);

?>

Output

quoted-printable-decode-string-function-in-php.gif

Up Next
    Ebook Download
    View all
    Learn
    View all