setFunctionName("web") ->setArgumentsTypes(["website"]) // single argument: website URL ); /** * 2. Implement the function * * @param string $website * @return string */ function web(string $website): string { // Ensure URL has a scheme if (!preg_match('~^https?://~i', $website)) { $website = "https://$website"; } // Escape for shell safety $escaped = escapeshellarg($website); // Run lynx and capture output $output = shell_exec("lynx -dump -nolist $escaped 2>/dev/null | head -n 250"); return $output ?: "[error] Unable to fetch $website"; }