如何从$ _SERVER [' HTTP_REFERER']中获取参数值?

时间:2016-08-31 13:24:08

标签: php laravel http-referer

在PHP应用程序中,$ _SERVER [' HTTP_REFERER']具有以下值:

http://testing.localhost/userdashboard/test/fc

我试过这个$value= striurl($_SERVER['HTTP_REFERER'], 'test');,我得到的值是test/fc

我的问题是提取" fc"的价值的正确方法是什么?

非常感谢您的帮助。

3 个答案:

答案 0 :(得分:1)

Laravel的Request类有一个名为segments()的函数,它返回url中所有段的数组。

这里是= ['userdashboard', 'test', 'fc']

所以考虑到这一点,你可以抓住最后一块......

$lastSegment = last(request()->segments());

答案 1 :(得分:1)

试试这个

import cv2
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

image = cv2.imread('sudokubig.jpg', 0)

if image is None:
    raise ValueError('Image not found!')

# background equalization
max_value = np.max(image)
backgroundRemoved = image.astype(float)
blur = cv2.GaussianBlur(backgroundRemoved, (151,151), 50)
backgroundRemoved = backgroundRemoved/blur
backgroundRemoved = (backgroundRemoved*max_value/np.max(backgroundRemoved)).astype(np.uint8)


fig = plt.figure(figsize=(20, 20))
plt.subplot(311),plt.imshow(image, 'gray'),plt.title('Input'),plt.axis('off')
plt.subplot(312),plt.imshow(backgroundRemoved, 'gray'),plt.title('Background Removed'),plt.axis('off')

ret, thres = cv2.threshold(backgroundRemoved,130,255,cv2.THRESH_BINARY)

# remove horizontal lines
kernel = np.ones((4, 1),np.uint8)
dilation1 = cv2.dilate(thres, kernel, iterations = 1)

# remove vertical lines
kernel = np.ones((1, 4),np.uint8)
dilation2 = cv2.dilate(dilation1, kernel, iterations = 1)

kernel = np.ones((3, 3),np.uint8)
erosion = cv2.erode(dilation2, kernel, iterations = 1)

plt.subplot(313),plt.imshow(erosion, 'gray'),plt.title('Final'),plt.axis('off')
plt.show()

kernel = np.ones((1, 4),np.uint8)
dilation = cv2.dilate(dilation, kernel, iterations = 1)

kernel = np.ones((3, 3),np.uint8)
erosion = cv2.erode(dilation, kernel, iterations = 1)

fig = plt.figure() 
plt.imshow(erosion, cmap='gray'),plt.title('missmatch')
plt.show()

答案 2 :(得分:0)

您正在寻找的功能是basename()

$base = basename('test/fc');
echo $base;  // fc

您可能还想查看parse_url(),它会将URL的所有元素提取为一个很好的数组结构。