2014-11-24 1 views
0

나는이 웹 사이트에 대한 스크립트 "당신은 여기에 있습니다"하고 노력하고 쓴 이야기 범주 그러나 출력은 별도의 뒤에 황소을 가지고 있으며, 그 이유를 알고 싶어하고 •내 스크립트의 출력이 • (?)인데 왜 그것을 제거하는 가장 좋은 방법이 있습니까?

<?php 
if (isset($_GET['pagina']) && isset($_GET['storycategory'])) { 
$pagina = $_GET['pagina']; 
$storycategory = $_GET['storycategory']; 
$storypage = $storycategory; 
$storypage = str_replace(stories, story, $storypage); 
$storypagename = $_GET[$storypage]; 
$content_path = 'You are here: Home &bull; ' . $pagina . ' &bull; ' . $storycategory . ' &bull; ' . $storypagename; 
$content_path = str_replace("-", " ", $content_path); 
echo '<strong>' . $content_path . '</strong><hr />'; // Voor een bezoeker die in een bepaald verhaal bezoekt - Output: You are here: Home • all stories • story category Name • Best story ever 
} 
elseif (isset($_GET['pagina']) && isset($_GET['storycategory'])) { // this is the part that has a trailing • that I'd like to remove and find out why it was created by my script 
    $pagina = $_GET['pagina']; 
    $storycategory = $_GET['storycategory']; 
    $content_path = 'You are here: Home &bull; ' . $pagina . ' &bull; ' . $storycategory; // Note: I did NOT add a • here but it is generated in output... 
    $content_path = str_replace("-", " ", $content_path); 
    echo '<strong>' . $content_path . '</strong><hr />'; // Voor een bezoeker die in een bepaalde alles uit deze story category pagina is! Output: You are here: Home You are here: Home • all stories • story category Name • 
    } 
    elseif (isset($_GET['pagina'])) { 
     $pagina = $_GET['pagina']; 
     $content_path = 'You are here: Home &bull; ' . $pagina; 
     $content_path = str_replace("-", " ", $content_path); 
     echo '<strong>' . $content_path . '</strong><hr />'; // Voor een bezoeker die op de alle sex stories pagina is! Output: Home • all stories 
     } 
     else { 
      // Als iemand verdwaald is en daardoor bovenstaande totaal niet van toepassing is... 
      echo '<strong>Thank you for visiting our site!</strong><hr />'; 
      } 
      ?> 

을 제거 할 것 Pagina는 훌륭하지만 후행은 없습니다.하지만 어떤 카테고리를 방문 할 때 (내가 코멘트를 보거나 코드에 표시하는 것을 좋아하지 않습니다) • 어떤 카테고리의 스토리 페이지를 방문 할 때도 있습니다. 아니오 • 마지막에 ...

나는 황소를 어떻게 제거해야하며 왜 생성 되었습니까?

읽어 주셔서 감사합니다.

편집 내 코드에서 사용한 변수를 설명하고 싶습니다.이 질문을 이해하는 데 도움이되기를 바랍니다.

좀 URL의이 있고 그들이 방문자에게하고 싶은 : 이야기에 대한

페이지 : www.example.com/index.php?pagina=all-stories & storycategory =을-가장 이야기 www.example.com/index.php?pagina=all-stories & storycategory = 더 - 최고의 이야기 : "가장 좋은 사례"내부의 모든 이야기 & 더 - 최고의 층 = 내-처음 컴퓨터

페이지

모든 스토리 카테고리의 페이지 : www.example.com/index.php?pagina=all-stories

나는이 폴더에 storycategory라는 폴더를 발견했다.이 폴더에는 storycategory 폴더에 엄청난 수의 폴더가 있으며 그 중 마지막 부분에 많은 이야기가있다. storycategory 폴더 안에있는 폴더에있는 mame (같은 이름이지만 storycategory에있는 php 파일의 스토리로 변경된 스토리)의 끝에있는 PHP 파일은 내 스토리가 저장되는 곳입니다.

1 부 : 가정 • 모든 이야기 • 최고의 이야기 • 내 첫 번째 컴퓨터 "이것은 잘 작동하고 있습니다.

 if (isset($_GET['pagina']) && isset($_GET['storycategory']) && isset($_GET['storycategory'])) { 
$pagina = $_GET['pagina']; 
$storycategory = $_GET['storycategory']; 
$storypage = $storycategory; 
$storypage = str_replace(stories, story, $storypage); 
$storypagename = $_GET[$storypage]; 
$content_path = 'You are here: Home &bull; ' . $pagina . ' &bull; ' . $storycategory . ' &bull; ' . $storypagename; 
$content_path = str_replace("-", " ", $content_path); 
echo '<strong>' . $content_path . '</strong><hr />'; // Voor een bezoeker die in een bepaald verhaal bezoekt - Output: You are here: Home • all stories • story category Name • Best story ever 
} 

2 부 문제

elseif (isset($_GET['pagina'])) { 
    $pagina = $_GET['pagina']; 
    $content_path = 'You are here: Home &bull; ' . $pagina; 
    $content_path = str_replace("-", " ", $content_path); 
    echo '<strong>' . $content_path . '</strong><hr />'; // Voor een bezoeker die op de alle sex stories pagina is! Output: Home • all stories 
    } 

내 코드의 제 4 부하지 않고, 너무 잘입니다

elseif (isset($_GET['pagina']) && isset($_GET['storycategory'])) { // this is the part that has a trailing • that I'd like to remove and find out why it was created by my script 
$pagina = $_GET['pagina']; 
$storycategory = $_GET['storycategory']; 
$content_path = 'You are here: Home &bull; ' . $pagina . ' &bull; ' . $storycategory; // Note: I did NOT add a • here but it is generated in output... 
$content_path = str_replace("-", " ", $content_path); 
echo '<strong>' . $content_path . '</strong><hr />'; // Voor een bezoeker die in een bepaalde alles uit deze story category pagina is! Output: You are here: Home You are here: Home • all stories • story category Name • 
} 

3 부 • 원치 않는 잘못 보내고하는 것은 다른 것입니다에 대한 이야기와 관련된 변수가 설정하거나 알 수없는 오류

경우
else { 
     // Als iemand verdwaald is en daardoor bovenstaande totaal niet van toepassing is... 
     echo '<strong>Thank you for visiting our site!</strong><hr />'; 
     } 

파트 2에 무엇이 잘못 되었나요? 아니면 결국 황소를 맞이해야합니까?

EDIT 2 경우 대체 편집 라인 2 (는 isset ($ _ GET [ 'PAGINA']) & &는 isset ($ _ GET [ 'storycategory']) & &는 isset ($ _ GET [ 'storycategory'])) { 와 경우 (는 isset ($ _ GET [ 'PAGINA']) & &는 isset ($ _ 끝에 •와 GET [ 'storycategory'])) {

문제가 storycategory 페이지에 여전히 존재, $storypage은 0에서 $storypagename을 생성하는 데 사용됩니다. str_replace 및 Home을 사용하는은 하드 코딩되어 있습니다.

EDIT 3 isset($_GET[$storypagename])) (2 호선) (해결)와 나는 같은 요청이 의견에 말했다 전에 그래서이를 찾아야했다 전에 $storypagename = $_GET[$storypagename];는 srories 글로벌 파일의 문제를 해결 못했지만, 어떤 변수가 정의되어야합니다 방법은 $storypagename 2 번째 줄에 정의했습니다. 모든 단일 페이지에 대한 모든 메타 태그 파일에서이를 정의했으며 완벽하게 작동합니다.

참고 : 마지막 2 개 굵은 부분 동적, 그래서 방문자가 다른 카테고리에있는 경우 마지막 url 변수가 변경됩니다. 스토리 페이지 : www.example.com/index.php?pagina=all-stories & storycategory = 더 - 최고의 이야기 & 이야기가있는 최고의 이야기 = 내-처음 컴퓨터 페이지 이 카테고리에서 : www.example.com/index.php?pagina=all-stories & storycategory = the-best-stories 모든 스토리 카테고리의 페이지 : www.example.com/index.php?pagina=all-stories 이야기

먼저 storycategory 값을 사용하여 str_replace()를 사용하려고 시도했지만 그것을 결코 정의 할 수 없기 때문에 메타 태그 파일의 작은 여분의 줄이 있다고 믿습니다.

내 사이트의 페이지 수가 10006이므로 array()은 옵션이 없었으며 모든 페이지에 메타 태그 php 파일을로드하고이 스크립트 앞에로드 된 후 $storypagename 변수를 정의하여 요청되기 전에 정의됩니다. 이 솔루션은 PHP 코드를 작게 만들었습니다. 내가 말하고 싶은

은 모두 답이 오류를 해결하기 위해이 방법을 찾을 도움이되었다, 모두 mudasobwa콘스탄틴에 감사합니다. 3 개 부품 모두 정상적으로 작동합니다. 다시 한 번 감사드립니다! 당신은 잘못 최초의 if 조건을 복사 - 붙여 넣기

<?php 
    if (isset($_GET['pagina']) && isset($_GET['storycategory']) && isset($_GET[$storypagename])) { 
    $pagina = $_GET['pagina']; 
    $storycategory = $_GET['storycategory']; 
    $storypagename = $_GET[$storypagename]; 
    $content_path = 'You are here: Home &bull; ' . $pagina . ' &bull; ' . $storycategory . ' &bull; ' . $storypagename; 
    $content_path = str_replace("-", " ", $content_path); 
    echo '<strong>' . $content_path . '</strong><hr />'; // Voor een bezoeker die in een bepaald verhaal bezoekt - Output: You are here: Home • all stories • story category Name • Best story ever 
    } 
    elseif (isset($_GET['pagina']) && isset($_GET['storycategory'])) { // this is the part that has a trailing • that I'd like to remove and find out why it was created by my script 
$pagina = $_GET['pagina']; 
$storycategory = $_GET['storycategory']; 
$content_path = 'You are here: Home &bull; ' . $pagina . ' &bull; ' . $storycategory; // Note: I did NOT add a • here but it is generated in output... 
$content_path = str_replace("-", " ", $content_path); 
echo '<strong>' . $content_path . '</strong><hr />'; // Voor een bezoeker die in een bepaalde alles uit deze story category pagina is! Output: You are here: Home You are here: Home • all stories • story category Name • 
} 
    elseif (isset($_GET['pagina'])) { 
    $pagina = $_GET['pagina']; 
    $content_path = 'You are here: Home &bull; ' . $pagina; 
    $content_path = str_replace("-", " ", $content_path); 
    echo '<strong>' . $content_path . '</strong><hr />'; // Voor een bezoeker die op de alle sex stories pagina is! Output: Home • all stories 
    } 
    else { 
     // Als iemand verdwaald is en daardoor bovenstaande totaal niet van toepassing is... 
     echo '<strong>Thank you for visiting our site!</strong><hr />'; 
       } 
       ?> 

답변

1

최종 작업 코드 :

if (
    isset($_GET['pagina']) && 
    isset($_GET['storycategory']) && 
    isset($_GET['storycategory'])) { // ERROR, should be $_GET['storypagename'] 

당신은 빈 $storypagename와이를 입력합니다.

$storypagename의 계산 여부에 관계없이이 조건은 항상 true 일 가능성이 높고 여기서는 else if 섹션을 입력하지 않으므로 여기에서 계산하여 확인해야합니다. mudasobwa으로

+0

네, 제 코드의 시작 부분에 있어야합니다. storypagename이 없으므로 먼저 정의하거나 $ storypagename을 확인하지 않아야합니다. (정의되어 있습니다. 7 호선에서 사용할 수 없으므로 2 호선에서 사용할 수 없습니다. 2 호선보다 먼저 정의하려고합니다. 더 좋을 것 같습니다. 그렇지 않으면 변경하면 오류가 반환됩니다. 이야기에 대한 내 링크를 게시 할 수 있습니다. 페이지에 있지만 성인용 이야기 URL을 게시 할 수 있는지 확실하지 않습니다. 첫 번째 부분과 마지막 부분이 작동하고 있습니다. 유일한 문제는 다음과 같습니다. 2 부 – jagb

+0

부분은 ** Part 1 **이며 Part 2는 아닙니다. 코드는 Part 2에 도달하지 않습니다. – mudasobwa

0

는 말했다 : 당신의 첫 번째 조건에서의 오류 (라인 2)

if (isset($_GET['pagina']) && isset($_GET['storycategory']) && isset($_GET['storycategory'])) { 

당신이 (라인 12)는 제 elseif 블록을 입력하지 않기 때문에 실행됩니다

라인입니다 라인 8 :

$content_path = 'You are here: Home &bull; ' . $pagina . ' &bull; ' . $storycategory . ' &bull; ' . $storypagename; 

그러나 $storypagename은 비어 있습니다. 끝 부분에 글 머리 기호로 끝나야합니다.

+0

내 코드를 설명하기 위해 내 게시물을 편집했으며 $ storypagename이 만들어졌습니다 라인 7, 이것은 첫 번째 부분이며 첫 번째 부분은 작동합니다. 내 사이트에 링크를 추가 할 수 있지만 여기에 게시 할 수 있는지 여부는 확실하지 않습니다. 모든 이야기는 성인용입니다. 그러나 내가 링크가 작동하는 것을 볼 수있을 것입니다, 답변 해 주셔서 감사합니다하지만 내 문제를 해결하지 못했지만 2 행에 중복 코드가 있음을 발견하고 2 행을 가리켜 주셔서 감사합니다! – jagb

+0

두 가지 답변이 모두 도움이되었습니다. 답변이 더 자세합니다. ** 최종 편집 가능한 코드를 작성하는 데 도움이되었습니다. ** 마지막'storycategory'가'$ storypagename'으로 변경되었으며이를 정의해야했습니다. 모든 페이지마다 모든 메타 태그 파일에서 마지막 500 페이지에 대해 500 줄을 작성해야합니다.이 질문에 답변 해 주셔서 감사합니다. 답변을 수락합니다. 문제의 절반을 다시 해결했습니다. 다시 감사드립니다. – jagb

관련 문제