Q:

PHP find output programs (String Functions) | set 2

belongs to collection: PHP Find Output Programs

0

Find the output of PHP programs | String Functions | Set 2: Enhance the knowledge of PHP String Functions concepts by solving and finding the output of some PHP programs.

Question 1:

<?php
    $A = 10;
    $B = 5;
    
    $C = $A * $B + 20;
    
    echo strrev($C);
?>

Question 2:

<?php
    $STR = "Include Help is educational platform";
    $POS = strpos($STR, "is");
    
    echo strrev($POS);
?>

Question 3:

<?php
    $STR = "Include Help is educational platform";
    $NEW_STR = str_replace("platform", "website", $STR);
    
    echo $NEW_STR;
?>

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Answer 1:

Output:

07

Explanation:

In the above program, we created two variables $A and $B initialized with 10 and 5 respectively. Let's evaluate the expression,

$C = $A*$B+20;
$C = 10*5+20;
$C = 50+20;
$C = 70;

After we reverse the value of $C, Then the strrev($C) will print 07 on the webpage.

Answer 2:

Output:

31

Explanation:

In the above program, we created a string $STR, which is initialized with "Include Help is educational platform" then we used strpos() function to find out the position of the substring "is" in the string $STR. Then function strops() return 13, which is assigned to variable $POS.

Finally, we print the reverse of $POS that will be 31.

Answer 3:

Output:

Include Help is an educational website

Explanation:

In the above program, we created a string $STR, which is initialized with "Include Help is educational platform" then we used str_replace() function to replace the specified substring inside the specified string.

Here, we replaced the "platform" substring by "website" in the string $STR. Then str_replace() returns the update string and assigned to $NEW_STR and then finally "Include Help is an educational website" will be printed on the web page.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

PHP Find Output Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
PHP find output programs (Number Functions) | set ... >>
<< PHP find output programs (String Functions) | set ...