Example #1
0
<?php

class Mystring
{
    public $value = "initial value";
    function mystrlen()
    {
        return strlen($this->value);
    }
}
$str1 = new Mystring();
$str1->value = "string value";
echo $str1->mystrlen();
        echo $a->somma($_POST["num2"]);
        echo "<br>";
        echo "=================================";
    }
    if ($_POST["operazione"] == "tasso") {
        echo "=================================";
        echo "prezzo con iva = ";
        echo $a->iva($_POST["num2"]);
        echo "<br>";
        echo "=================================";
    }
}
echo "=================================";
echo "<br/>";
if (isset($_POST["ribalta"])) {
    $ribalta = new Mystring($_POST["ribalta"]);
    echo "<br>";
    echo "stringa ribaltata iva = ";
    echo $ribalta->ribaltastringa();
    echo "<br>";
    echo "=================================";
    if (isset($_POST["ricerca"]) && $_POST["ricerca"] != "") {
        echo "<br>";
        echo "stringa ricercata = ";
        echo $_POST["ricerca"];
        echo "<br>";
        $stringhedivise = $ribalta->dividi($_POST["ricerca"]);
        echo "stringhe divise ";
        echo "<br>";
        echo "prima stringa -------- ";
        echo $stringhedivise[0];
					<option value="divide">Divide</option>
					<option value="bold">Bold</option>				
				</select>
				<br />			
				<input type="submit" value="GO" />
			</form>
		</p>
	</body>
</html>



<?php 
include "ribaltastringa_class.php";
if (isset($_POST['string']) && isset($_POST['divider'])) {
    $textModifier = new Mystring($_POST['string'], $_POST['divider']);
    switch ($_POST['textmodify']) {
        case "reverse":
            echo "Reversed string is ->" . $textModifier->reverseString() . "<br />";
            break;
        case "divide":
            if ($_POST['string'] != "" && $_POST['divider'] != "") {
                $output = $textModifier->divideString();
                echo "Text input is -> '" . $_POST['string'] . "'<br />" . "Divider is -> '" . $output[0] . "'<br />" . "Modified text is: <br />First part -> '" . $output[1] . "'<br />Second part -> '" . $output[2] . "'";
                exit;
            } else {
                echo "You need to input something!";
            }
            break;
        case "bold":
            if ($_POST['string'] != "" && $_POST['divider'] != "") {