yout - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of yout.php

  1. <?php
  2. function create_description($title, $description, $tags)
  3. {
  4.     $array = array();
  5.     $array[] = $title;
  6.     $array[] = $description;
  7.     $array[] = $tags;
  8.     return $array;
  9. }
  10. if (isset($_POST['submit'])) {
  11.     /**
  12.      * @param $title
  13.      * @param $description
  14.      * @param $tags
  15.      * @return array
  16.      */
  17.     $description = $_POST['description'] ?? '';
  18.     $title = $_POST['title'] ?? '';
  19.     $tags = $_POST['tags'] ?? '';
  20.  
  21.     $results = array();
  22.     if ($description && $title && $tags) {
  23.         $results = create_description($title, $description, $tags);
  24.     }
  25. }
  26.  
  27. ?>
  28. <html>
  29. <head>
  30.     <title>Youtube description</title>
  31.     <link rel="stylesheet" href="../src/template/style.css">
  32. </head>
  33. <body>
  34. <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  35.     <div>
  36.         <input type="text" name="title" id="title" placeholder="Title" />
  37.     </div>
  38.     <div>
  39.         <textarea name="description" id="description" cols="30" rows="10" placeholder="Description"><?php echo $description; ?></textarea>
  40.     </div>
  41.     <div>
  42.         <input type="text" name="tags" id="tags" placeholder="tags" />
  43.     </div>
  44.     <div>
  45.         <button type="submit" name="submit" id="submit">
  46.             Create description
  47.         </button>
  48.     </div>
  49. </form>
  50.  
  51. <div class="descriptioncontents">
  52.     <?php
  53.         if($results){
  54.             foreach ($results as $result){
  55.                 echo "<div>". $result['title'] ."</div>";
  56.                 echo "<div>". $result['description'] ."</div>";
  57.                 echo "<div>". $result['tags'] ."</div>";
  58.             }
  59.         }
  60.     ?>
  61. </div>
  62.  
  63. </body>
  64. </html>
File Description
  • yout
  • PHP Code
  • 28 Jun-2022
  • 1.63 Kb
You can Share it: