/** * * @param point $point */ public function equals($point) { return $this->_x == $point->getX() && $this->_y == $point->getY(); }
<!doctype html> <?php require_once 'vektor.php'; $a = new point(0, 0); $b = new point(0, 0); ?> <html lang="cs"> <head> <meta charset="utf-8"> <title>Body v prostoru</title> <link rel="stylesheet" href="style.css" type="text/css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script type="text/javascript" href="https://code.jquery.com/jquery-2.1.4.min.js"></script> </head> <body class="container"> <header> <h1>Body v prostoru</h1> </header> <div class="row"> <form class="form col-md-12" method="post" action="index.php"> <div class="col-xs-8 col-md-6"> <input type="text" class="form-control" id="A1" name="A1" placeholder="A1" value=<?php if (isset($_POST["submit"])) { $a->prvni($_POST['A1']); } ?> > </div> <div class="col-xs-8 col-md-6"> <input type="text" class="form-control" id="A2" name="A2" placeholder="A2" value=<?php if (isset($_POST["submit"])) {
<?php require __DIR__ . '/../vendor/autoload.php'; use tarcisio\p2d\Point; use tarcisio\p2d\Line; $p1 = new Point(10, 10); $p2 = new point(20, 20); $p2->multiply($p1->x, 0); $line = new Line($p1->x, $p1->y, $p2->x, $p2->y); print $p1 . PHP_EOL; print $p2 . PHP_EOL; print $line . PHP_EOL;
<?php /*СОЗДАНИЕ КЛАССА*/ //Классы лучше создавать в отдельных файлах require_once getenv("DOCUMENT_ROOT") . "/lib/config.php"; require_once "point.php"; $point = new point(5, 7); //Оператор new - создает новый объект $point2 = new point(2); $point2->x = 30; $point2->y = 0; //передаем значения свойств нового объекта echo $point->x . "<br/>"; echo $point->y . "<br/>"; //"->" - с помощью этого знака обращаются к свойствам объекта echo point::CONSTANT . "<br/>"; // :: - с помощью этого знака обращаются к константам объекта echo $point->sum() . "<br/>"; //-> - так же обращаемся к методу объекта echo $point->length(10, 5) . "<br/>"; echo $point->lengthObject($point2) . "<br/>"; unset($point); unset($point2); echo "<br/>----------------<br/>";
<!doctype html> <?php if (isset($_POST["submit"])) { require_once 'vektor.php'; $a = new point(0, 0); $b = new point(0, 0); $c = new point(0, 0); $d = new point(0, 0); } ?> <html lang="cs"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="theme-color" content="#286090"> <title>Body v prostoru</title> <link rel="stylesheet" href="style.css" type="text/css"> <link rel="stylesheet" type="text/css" href="jsxgraph.css" /> <link rel="icon" sizes="192x192" href="android-ico.png"> <script type="text/javascript" src="jsxgraphcore.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script> </head> <body class="container"> <header> <h1>Body v prostoru</h1> </header> <div class="row"> <form class="form col-md-12" method="post" action="index.php"> <div class="col-xs-10 col-md-6"> <input type="number" class="form-control" name="A1" placeholder="A1" value=