第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

附屬標(biāo)簽未在鏈接中正確添加

附屬標(biāo)簽未在鏈接中正確添加

PHP
大話西游666 2023-05-12 14:22:04
我正在嘗試使用 php 創(chuàng)建附屬鏈接 geenrator,我正在使用以下代碼生成。但是只有當(dāng)鏈接包含任何附屬標(biāo)簽時(shí),此代碼才在鏈接的最后添加 affid。如果我使用此鏈接,則“ https://www.flipkart.com/whirlpool-1-5-ton-5-star-split-inverter-ac-white/p/itmf8fb8a675505d?pid=ACNFE6K2BXFY6EKX ”它會(huì)向我發(fā)送相同的信息鏈接而不添加任何標(biāo)簽。任何人都可以幫我解決這個(gè)問題嗎?$url = "https://www.flipkart.com/whirlpool-1-5-ton-5-star-split-inverter-ac-white/p/itmf8fb8a675505d?pid=ACNFE6K2BXFY6EKX";      $afftag = 'harshk'; //our affiliate ID        $affstring = 'affid='; // url parameter for affiliate ID        if (parse_url($url, PHP_URL_QUERY)): //check if link has query string            if (strpos($affstring, $url) !== true) : //check if link already has affiliate ID                $url = preg_replace("/(".$affstring.").*?(\z|&)/", "$1".$afftag."$2", $url);        else:                $url = $url.'&'.$affstring.$afftag;            endif;        else:            $url = $url.'?'.$affstring.$afftag;        endif;
查看完整描述

1 回答

?
臨摹微笑

TA貢獻(xiàn)1982條經(jīng)驗(yàn) 獲得超2個(gè)贊

試試這是否有效


$url = "https://www.flipkart.com/whirlpool-1-5-ton-5-star-split-inverter-ac-white/p/itmf8fb8a675505d?pid=ACNFE6K2BXFY6EKX";

$afftag = 'harshk'; //our affiliate ID

$affstring = 'affid='; // url parameter for affiliate ID

if (parse_url($url, PHP_URL_QUERY)): //check if link has query string

    if (strpos($affstring, $url) === true) : //check if link already has affiliate ID

        $url = preg_replace("/(" . $affstring . ").*?(\z|&)/", "$1" . $afftag . "$2", $url);

    else:

        $url = $url . '&' . $affstring . $afftag;

    endif;

else:

    $url = $url . '?' . $affstring . $afftag;

endif;

解決方案#2


<?php


$urlStr = "https://www.flipkart.com/whirlpool-1-5-ton-5-star-split-inverter-ac-white/p/itmf8fb8a675505d?pid=ACNFE6K2BXFY6EKX";

$afftag = 'harshk'; //our affiliate ID

$affstring = 'affid'; // url parameter for affiliate ID

$url_components = parse_url($urlStr);

$params = [];

if (isset($url_components['query'])):

    parse_str($url_components['query'], $params);

endif;

$url = "{$url_components['scheme']}://{$url_components['host']}{$url_components['path']}";

$params[$affstring] = $afftag;

$url .= "?" . http_build_query($params);


查看完整回答
反對(duì) 回復(fù) 2023-05-12
  • 1 回答
  • 0 關(guān)注
  • 184 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)