문제

I need to run a php condition to check for the text that's clicked in a tab. I need to check the text value instead of the url as the url is the same, only text is different. Here's what I have so far:

<a href="/some-value">Tab 1</a> 
<a href="/some-value">Tab 2</a> 

<?php 
    $a = 'Tab 1'; //How to check for this value?
    $b = 'Tab 2';

    if (strpos($a,'Tab 1') !== false) {
        echo 'Tab 1'; 
    } else { 
        echo 'Tab 2'; 
    } 
?>
도움이 되었습니까?

해결책

i think it will be better to set the text of anchor in the url.

Like this:

<a href="/some-value?tab=Tab 1">Tab 1</a> 
<a href="/some-value?tab=Tab 2">Tab 2</a> 

And then if you want to know which tab clicked just get the tab value

$_REQUEST['tab']
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top