Home Tutorial Php Examples Modifying the Path Example.

 
 

Modifying the Path Example.
Posted on: July 30, 2009 at 12:00 AM
Advertisement
In this example you will learn how to modify the corrupt Path.

Modifying the Path

In this example, you will learn how to modify the corrupted path using $outpath command in PHP. This command will modify the path in the correct way if it finds any error syntax in the defined path. The $outpath command will automatically correct by way of replacing the defined value in the program and if it finds it during compilation. After detecting the correct path it replaces the correct one with alteration path. Let's see the below example in steps:

First Begin the HTML tag, under it HTML Body and then begin the PHP tag.

Now, you set the output of the path with conditional statement using isset(); command. As we have set the path if (isset($_POST['posted'])). 

Define the outpath with special characters and characters, and print the old or new path.

End the PHP tag.

Now begin the form action and call the outpath code on the same page and print the value on the same page.

Set the dimension of output text box.

Close the form, close the HTML Body and tag.

isset  

<html>
<body>
<?php
// Setting output of the path
if (isset($_POST['posted'])) {
$path = $_POST['path'];
$outpath = ereg_replace("\.[\.]+", "", $path);
$outpath = ereg_replace("^[\/]+", "", $outpath);
$outpath = ereg_replace("^[A-Za-z][:\|][\/]?", "", $outpath);
echo "The old path is " . $path . " and the new path is " . $outpath;
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="posted" value="true">
Enter your file path for cleaning:
<input type="text" name="path" size="30">
<input type="submit" value="Clean">
</form>
</body>
</html>

In the out put it will show the new path by eliminating the above defined symbol.


 

Advertisement

Related Tags for Modifying the Path Example.:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 30, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com