From fbab3513058c7556101de6ab234bbf9bc98eed44 Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Mon, 28 Jul 2014 11:45:09 +0200 Subject: [PATCH] Added check if article was found --- 1stPara.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/1stPara.php b/1stPara.php index 3872094..d78a24b 100755 --- a/1stPara.php +++ b/1stPara.php @@ -9,6 +9,13 @@ if (!isset($argv[1])) $url = $argv[1]; $data = shell_exec("curl -s $url"); preg_match("/\(.*)\<\/p\>/", $data, $match); + +if (!isset($match[1])) +{ + print "No Wikipedia article found at that URL\n"; + exit(1); +} + $string = strip_tags($match[1]); print (wordwrap($string, 60, "\n") . "\n");