Skip to main content

Write a PHP script, which will return the following components of the url 'http://localhost/ex/php/8.php'.

Write a PHP script, which will return the following components of the url 'http://localhost/ex/php/8.php'.


<?php
$url1 ='http://www.w3resource.com/php-exercises/php-basic-exercises.php';  
$url = 'http://localhost/ex/php/8.php';  
$url=parse_url($url);  
echo "<pre>";
print_r($url);
echo 'Scheme : '.$url['scheme'].'<br />';  
echo 'Host : '.$url['host'].'<br />';  
echo 'Path : '.$url['path'].'<br />';  
?>




Comments

Popular posts from this blog

$var = 'PHP Tutorial'. Put this variable into the title section, h3 tag and as an anchor text within a HTML document.

$var = 'PHP Tutorial'. Put this variable into the title section, h3 tag and as an anchor text within a HTML document.  <?php echo "<html>"; echo "<head>"; echo "<title>"; echo "PHP TUTORIAl"; echo "</title>"; echo "<body>"; echo "<h3>PHP TUTORIAL</h3>"; echo "<hr>"; echo "<p>PHP, an acronym for Hypertext Preprocessor, is a widely-used open source general-purpose scripting language. It is a cross-platform, HTML embedded server-side scripting language and is especially suited for web development.</p>"; echo "</body>"; echo "</head>"; echo "</html>"; ?> Output:

Create a simple HTML form and accept the user name and display the name through PHP echo statement.

Create a simple HTML form and accept the user name and display the name through PHP echo statement. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Post Data</title> </head> <body> <form method="POST" action=""> <label>Enter First Name</label> <input type="text" name="firstname" id="firstname" /> <input type="submit" name="submit_button" value="Submit Name" /> </form> </body> </html> <?php if(isset($_POST) && !empty($_POST)) { echo "<h3> Hello ".$_POST['firstname']."</h3>"; } ?> Output:

Write a PHP script, which change the color of first character of a word.

Write a PHP script, which change the color of first character of a word. <?php   $text = 'PHP Tutorial';   $text = preg_replace('/(\b[a-z])/i','<span style="color:red;">\1</span>',$text);   echo $text;   ?>