在这种情况下,我需要找到服务器目录路径和项目所基于的公共路径之间的重叠。
<v-btn id="price" flat small @click="idcheck(this.id)">Price</v-btn>
methods: {
idcheck(id){
alert(id);
}
我四处寻找答案,找到了部分解决方案。
我可以用'/'分割字符串并创建数组,然后使用array_intersect(),但是我得到了...
# Install the smartsheet sdk with the command: pip install smartsheet-python-sdk
import smartsheet
import logging
import os.path
import json
# TODO: Set your API access token here, or leave as None and set as environment variable "SMARTSHEET_ACCESS_TOKEN"
access_token = None
print("Starting ...")
# Initialize client
smart = smartsheet.Smartsheet(access_token)
# Make sure we don't miss any error
smart.errors_as_exceptions(True)
# Log all calls
logging.basicConfig(filename='rwsheet.log', level=logging.INFO)
response = smart.Workspaces.list_workspaces(include_all=True)
workspaces = response.data
with open('data.json', 'w') as outfile:
json.dump(workspaces, outfile)
print("Done")
我不想包含“ home”文件夹,因为它不在URI中。
答案 0 :(得分:1)
这是我的方法。我还没有测试它是否比@Adam 的更快,但我认为它看起来更干净。
$dir = $_SERVER['SCRIPT_FILENAME'];
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$intersection = implode('/',
call_user_func_array('array_intersect',
array_map(function($a) {
return explode('/', $a);
},
[$dir, $uri])
)
);
$uri_result = substr($request_uri, strlen($intersection));
答案 1 :(得分:0)
所以我想出了一个答案:
$dir = '/server/home/this/directory/to/public/my_app/';
$uri = '/my_app/home/script.php';