Лехин Код - 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.
Result of php executing
Full code of Лехин Код .php
- <?php
- class Current {
- public $next;
- public $value;
- }
- function init() {
- $root = new Current();
- $c = $root;
- for($i=1;$i<5;$i++){
- $c->next = new Current();
- $c->value = $i;
- $c=$c->next;
- }
- return $root;
- }
- // function print_c($current){
- // while ($current) {
- // print("\$current->val = {$current->val}")
- // }
- // }
- function rev($current) {
- $prev = null;
- while ($current) {
- $next = $current->next;
- $current->next = $prev;
- $prev = $current;
- $current = $next;
- }
- return $prev;
- }
- function app(){
- $test = init();
- print_r($test);
- $rev = rev($test);
- print_r($rev);
- }
- app();