单链表2021/4/19特点土办法实现特点链表有这样一些特点。以节点的方式进行存储。每个节点包含 data 域和 next 域,data 域用于存储数据,next 域用于指向下一个节点。链表的各个节点在内存中不一定是连续的。链表有带头节点的和不带头结点的。土办法实现 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 <?php class Node { public $data; public $next; public function __construct($data = null, self $next = null) { $this->data = $data; $this->next = $next; } } $head = new Node(); $node1 = new Node('node1'); $node2 = new Node('node2'); $head->next = $node1; $node1->next = $node2; var_dump($head->next->next->data); // 输出 node2 从上面的最后一行代码可以看出,只要拿到 head 就可以顺着链子,找到任何一个 node 。