1
나는 PHP 오류가있어 인터넷을 통해 내 모든 scrummaging 통해 - 나는 아직 균열 수 없습니다.PHP 오프셋 오류
오류는 말한다 :
Error message Notice: Undefined offset: 3 in include() (line 89 of /home/devced/public_html/site/sites/all/themes/cedncsu/page.tpl.php).
그래서, 내 코드를 둘러보고, 나는 현재 (실제 사용은 아래 주석)이 있습니다
<?php
// Get Base URL
global $base_url;
// Get the Page's Parent Menu Item
$menuParent = menu_get_active_trail();
// Since it returns an array, make sure to target what you are looking for
// You should print_r what menu_get_active_trail() to see what else it gives you
$menuParent = $menuParent[1]['link_title'];
$menuParent = strtolower(str_replace(" ", "-", $menuParent));
$menuParent = preg_replace('/[^\w\d_ -]/si', '', $menuParent);
// Generate class specific for department page headers
$menuParentDepartment = menu_get_active_trail();
$menuParentDepartment = $menuParentDepartment[3]['link_title']; // This is where they say the error is
$menuParentDepartment = strtolower(str_replace(" ", "-", $menuParentDepartment));
$menuParentDepartment = preg_replace('/[^\w\d_ -]/si', '', $menuParentDepartment);
// Current Page space replace/lowercase
$currentTitle = strtolower(str_replace(" ", "-", $title));
$currentTitle = preg_replace('/[^\w\d_ -]/si', '', $currentTitle);
?>
내가이 일반적인 코딩 연습이다 생각 나는 실종되었지만, 지금까지 멀리 떨어진 상태 다. 어떤 도움이라도 대단히 감사하겠습니다. 감사!
+1, @Zach는 menu_get_active_trail()이 항상 3 또는 3 개 이상의 배열 요소를 반환한다고 확신합니까? – GoodSp33d
달콤한! Yup @ kantu, 그게 완벽한 감각을 "왜"그것은 오류를 보여줄 것입니다 - 항상 그렇지 않기 때문에, 그래서 만약 그 값이 3 번째 위치에 있는지 아닌지를 확인한다면, 그 다른 부분을 실행하면 다른 경우에는 쓸모가 없어야합니다. 도와 주셔서 감사합니다! – Zach