<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
//code for counties in my Registration page
<?php
function is_valid_state($county) {
$validCounties = array ( "Avon","Bedfordshire","Berkshire","Borders","Buckinghamshire","Cambridgeshire","Central","Cheshire","Cleveland","Clwyd","Cornwall","County Antrim","County Armagh","County Down","County Fermanagh","County Londonderry","County Tyrone","Cumbria","Derbyshire","Devon","Dorset","Dumfries and Galloway","Durham","Dyfed","East Sussex","Essex","Fife","Gloucestershire","Grampian","Greater Manchester","Gwent","Gwynedd County","Hampshire","Herefordshire","Hertfordshire","Highlands and Islands","Humberside","Isle of Wight","Kent","Lancashire","Leicestershire","Lincolnshire","Lothian","Merseyside","Mid Glamorgan","Norfolk","North Yorkshire","Northamptonshire","Northumberland","Nottinghamshire","Oxfordshire","Powys","Rutland","Shropshire","Somerset","South Glamorgan","South Yorkshire","Staffordshire","Strathclyde","Suffolk","Surrey","Teesside","Tyne and Wear","Warwickshire","West Glamorgan","West Midlands","West Sussex","West Yorkshire","Wiltshire","Worcestershire",);
if (in_array($county,$validCounties)) {
return true;
} else {
return false;
}
} //end function is_valid_county
// Dreamweaver suggests that the error lies in here? I have been trying for the last few hours to try and locate it to no avail and I would really appreciate some help
function is_valid_postcode($postcode) {
if (preg_match('/^[\d]+$/',$postcode)) {
return true;
} else is (strlen($postcode) == 5 || strlen($postcode) == 9) {
return true;
} else {
return false;
}
} //end function is_valid_postcode
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
答案 0 :(得分:1)
else if
而非else is
下面
} else is (strlen($postcode) == 5 || strlen($postcode) == 9) {
-------^^ // Replace that to if
答案 1 :(得分:1)
错误else is
应为else if
..
} else is (strlen($postcode) == 5 || strlen($postcode) == 9) {