傾旎

文章 评论 浏览 28

傾旎 2025-02-20 23:37:28

不要损害已经给出的答案,而是要注意跑到这个的人……

  1. “ color col = colors.white” - 颜色和颜色不是同一件事情,而“颜色”中有System.Drawing.Color和Microsoft.maui.graphics.Color,所以要小心您不要意外混合类型。
  2. 如果您在C#而不是XAML中进行UI,则可以直接绑定到颜色,然后摆脱所有字符串转换。

编辑:从那以后,我写了一个博客,讲述了如何在c#中创建Maui UI

Not to detract from the answer already given, but a couple of points to note for people running into this...

  1. "Color col = Colors.White" - Color and Colors aren't the same thing, and within "Color" there is System.Drawing.Color and Microsoft.Maui.Graphics.Color, so be careful you're not accidentally mixing types.
  2. If you do your UI in C# rather than XAML, then you can just bind directly to a Color to begin with and get rid of all the string-converting.

EDIT: I have since written a blog on how to write your UI in C# Creating MAUI UI's in C#

.NET MAUI:如何在结合中引用颜色?

傾旎 2025-02-20 20:33:55

您可以使用此言论:

/(?<=(^|>)[^<>]*)\btext\b/g

说明:

(?

大于符号&gt;

[^&lt;&gt;]* - 随后零或更多任何字符的零或更多不为&lt;&gt;

- 在 \ btext \ b 后面的结尾

- 匹配一个单词折断是 text 和另一个单词break,

它使用 global 标志。

现在,用 xxxx 或其他任何代替。

您可以在这里看到它:

You can use this regex:

/(?<=(^|>)[^<>]*)\btext\b/g

Explanation:

(?<= - look behind

(^|>) - for start of text OR a greater than sign >

[^<>]* - followed by zero or more of any character not being <>

) - end of look behind

\btext\b - match a word break followed be text and another word break

It's using the global flag.

Now replace with xxxx or whatever.

You can see it here: https://regex101.com/r/LX6UwH/1

(无法使用DOM)JavaScript正则表达式匹配文本和过滤HTML标签

傾旎 2025-02-20 15:49:19

您似乎在第一个片段中有一个凹痕问题。只需将返回数据语句向左移动以将其从while块中删除。除此之外,您似乎并不清楚您正在观看的条件是什么,以结束循环的执行。 i 推测您要在没有更多值附加到行列表的值之后立即返回数据。如果是这样,那么这可能是一个解决方案:

def recordData(memory_service):
""" Record the data from ALMemory.
    Returns a matrix of values
"""
print "Recording data ..."
data = list()

# while program is running, record data
print "4"
kickCall()

while True:
    print "5"
    line = list()

    for key in ALMEMORY_KEY_NAMES:
        print "6"
        value = memory_service.getData(key)
        line.append(value)
    print "7"

    if len(line) == 0:
        break

    data.append(line)

return data

当心条件语句如果Len(line)== 0:也可以将其重写为,如果不是line:。我之所以选择第一份表单仅是为了清楚性:我们正在评估 line 列表中的元素数量是否为零,而不是name line 引用的值。评估为真或错误。

You seem to have an indentation problem in your first snippet. Just move the return data statement to the left to remove it from the while block. Other than that you don't seem to make it clear what is the condition you are watching to end the execution of the loop. I speculate that you want to return the data as soon as there are no more values to append to the line list. If that's the case, then this might be a solution:

def recordData(memory_service):
""" Record the data from ALMemory.
    Returns a matrix of values
"""
print "Recording data ..."
data = list()

# while program is running, record data
print "4"
kickCall()

while True:
    print "5"
    line = list()

    for key in ALMEMORY_KEY_NAMES:
        print "6"
        value = memory_service.getData(key)
        line.append(value)
    print "7"

    if len(line) == 0:
        break

    data.append(line)

return data

Beware that the conditional statement if len(line) == 0: could also be rewritten as if not line:. The reason I chose the first form was exclusively for clarity: We are evaluating if the number of elements in the line list is zero, not if the value referenced by the name line evaluates as true or false.

如何检查使用python方法是否正在使用时循环运行?

傾旎 2025-02-20 08:07:16

根据Marko Nikolovski的说法,

这里的答案是Objective-C答案:

- (void)ViewDidLoad {
[self addDoneButtonOnKeyboard];
}

- (void)addDoneButtonOnKeyboard {
UIToolbar *toolBarbutton = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
toolBarbutton.barStyle = UIBarStyleBlackTranslucent;

UIBarButtonItem *barBtnItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *done = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(doneButtonAction)];

NSMutableArray *items = [[NSMutableArray alloc] init];
[items addObject:barBtnItem];
[items addObject:done];

toolBarbutton.items = items;
[toolBarbutton sizeToFit];

self.timeoutTextField.inputAccessoryView = toolBarbutton;
}

- (void)doneButtonAction {
[self.view endEditing:YES];
}

According to Marko Nikolovski answer

Here is objective-C answer :

- (void)ViewDidLoad {
[self addDoneButtonOnKeyboard];
}

- (void)addDoneButtonOnKeyboard {
UIToolbar *toolBarbutton = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
toolBarbutton.barStyle = UIBarStyleBlackTranslucent;

UIBarButtonItem *barBtnItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *done = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(doneButtonAction)];

NSMutableArray *items = [[NSMutableArray alloc] init];
[items addObject:barBtnItem];
[items addObject:done];

toolBarbutton.items = items;
[toolBarbutton sizeToFit];

self.timeoutTextField.inputAccessoryView = toolBarbutton;
}

- (void)doneButtonAction {
[self.view endEditing:YES];
}

如何添加“完成”使用SWIFT在iOS中进行numpad的按钮?

傾旎 2025-02-20 07:11:40

css只能向下穿越,孩子永远不会对其样式应用
父/上一个兄弟姐妹。

因此,最好的情况是将 .Section-Body 作为第一个孩子并隐藏每个兄弟姐妹。它不会隐藏

.section-body:empty ~ * {
    display: none;
}
<section>
  <div class="section-body">
      Lorem ipsum dolor sit amet consectetur, adipisicing elit. Itaque minima repudiandae sequi ex voluptatem illo, hic tempora recusandae commodi, similique earum laudantium deleniti atque placeat nemo, aperiam ullam dicta quae.
  </div>
  <h1>This will not be hidden</h1>
</section>
<section>
  <p>Down side siblings can't be selected</p>
  <div class="section-body"></div>
  <h1>This will be hidden</h1>
</section>
<section>
  <div class="section-body">
  </div>
  <p>Having new line is not empty</p>
</section>

<section>
  <div class="section-body"></div>
  <h1>This will be hidden.</h1>
</section>

让我们的“ Little Hack ”, .Section-Body:empty〜 *将选择每个:empty 具有class section> section-body 的标签,我们可以使用)和使用*将选择所有这些。

Cons:

  • You need to change structure
  • If you have new lines, spaces or anything , this will not be empty

So a betther solution is to use javascript

And here is simple vanilla <强> JavaScript 解决方案

document.querySelectorAll("section > .section-body").forEach(function (el) {
    if (el.textContent.trim() === '') {
        el.parentNode.style.display = "none";
    }
});
 <section>
    <h1>TITLE</h1>
    <div class="section-body">
        Lorem ipsum dolor sit amet consectetur, adipisicing elit. Itaque minima repudiandae sequi ex voluptatem illo, hic tempora recusandae commodi, similique earum laudantium deleniti atque placeat nemo, aperiam ullam dicta quae.
    </div>            
</section>
<section>
    <h1>TITLE 2</h1>
    <div class="section-body">                
    </div>
</section>

CSS can only traverse downward, a child can never apply a style to its
parent/previous siblings.

So your best case scenarion is to place .section-body as first child and hide every sibling. It'll not hide section

.section-body:empty ~ * {
    display: none;
}
<section>
  <div class="section-body">
      Lorem ipsum dolor sit amet consectetur, adipisicing elit. Itaque minima repudiandae sequi ex voluptatem illo, hic tempora recusandae commodi, similique earum laudantium deleniti atque placeat nemo, aperiam ullam dicta quae.
  </div>
  <h1>This will not be hidden</h1>
</section>
<section>
  <p>Down side siblings can't be selected</p>
  <div class="section-body"></div>
  <h1>This will be hidden</h1>
</section>
<section>
  <div class="section-body">
  </div>
  <p>Having new line is not empty</p>
</section>

<section>
  <div class="section-body"></div>
  <h1>This will be hidden.</h1>
</section>

Let examin our "little hack", .section-body:empty ~ * will select every :empty tag that have a class section-body, we can get next sibligs with ~ and using * will select all of them.

Cons:

  • You need to change structure
  • If you have new lines, spaces or anything , this will not be empty

So a betther solution is to use javascript

And here is simple vanilla javascript solution

document.querySelectorAll("section > .section-body").forEach(function (el) {
    if (el.textContent.trim() === '') {
        el.parentNode.style.display = "none";
    }
});
 <section>
    <h1>TITLE</h1>
    <div class="section-body">
        Lorem ipsum dolor sit amet consectetur, adipisicing elit. Itaque minima repudiandae sequi ex voluptatem illo, hic tempora recusandae commodi, similique earum laudantium deleniti atque placeat nemo, aperiam ullam dicta quae.
    </div>            
</section>
<section>
    <h1>TITLE 2</h1>
    <div class="section-body">                
    </div>
</section>

仅使用CSS使用CHILD HTML元素是空的,如何隐藏父元素元素?

傾旎 2025-02-20 05:31:43

您可以使用以下行。

first, *middle, last = fullnames.split()

You can use the following line instead.

first, *middle, last = fullnames.split()

熊猫的全名分为一个,中间和姓氏

傾旎 2025-02-19 08:36:10

在for循环中,您将CCI_Words投入到下行中的列表中,因此您的程序第二次通过循环进行迭代后会丢弃错误,并尝试在CCI_Words上调用Lower()。

cci_words = [ ele.strip() for ele in words ]

如果您希望列表中的任何单词返回true,您似乎使这个问题很复杂,可以做这样的事情。

def words_in_url_list(words: List[str], url_list: List[str]) -> bool:
    count = 0
    for word in words:
        word = word.lower()
        [count += 1 for url in url_list if word in url]
    return count > 0

如果您想检查列表中的所有单词,可以尝试此方法。

def all_words_in_url_list(words: List[str], url_list: List[str]) -> bool:
    comparison: set[str] = set()
    for word in words:
        word = word.lower()
        [comparison.add(word) for url in url_list if word in url]
    return len(words) == len(comparison)
        

In your for loop you cast cci_words to a list in the below line, so your program is throwing an error after it iterates through the loop a second time and tries to call lower() on cci_words.

cci_words = [ ele.strip() for ele in words ]

You seem to be making this probem quite complex where you could do something like this if you want any word in the list being present to return True.

def words_in_url_list(words: List[str], url_list: List[str]) -> bool:
    count = 0
    for word in words:
        word = word.lower()
        [count += 1 for url in url_list if word in url]
    return count > 0

If you want to check for all the words in the list, you could try this approach.

def all_words_in_url_list(words: List[str], url_list: List[str]) -> bool:
    comparison: set[str] = set()
    for word in words:
        word = word.lower()
        [comparison.add(word) for url in url_list if word in url]
    return len(words) == len(comparison)
        

在使用Python的URL列表中搜索特定单词列表

傾旎 2025-02-19 05:42:15

正如大卫提到的那样,我错过了一个-build-arg,然后在变体之前= CPU

As David mentioned, I had missed one --build-arg before VARIANT=cpu

错误的“ docker构建”完全需要1个参数

傾旎 2025-02-19 01:39:57

您无需安装Postgres依赖项。您只需要在app-config.yaml中正确配置Postgres即可。

you don't need to install a postgres dependency. You only need to configure Postgres correctly in the app-config.yaml.

dockerfile后台的postgresql依赖性变量

傾旎 2025-02-18 21:07:44

正如错误所说的那样,未经授权

您没有为Avro Serde配置提供身份验证设置。

注意” 。您给出的其余链接似乎是“本地开发 /入门”,并且不

同样涵盖安全配置,您需要 properties < / code>变量中的SASL属性才能连接到实际经纪人,假设这不是 streams.properties 文件...

汇合云需要身份验证,该设置的值应在群集仪表板中显示。

如果没有身份验证,任何人都可以在您的问题中复制代码并开始发送/消费随机数据;)

As the error says, Unauthorized.

You have given no authentication settings to your avro serde config.

Notice from docs - basic.auth.credentials.source + schema.registry.basic.auth.user.info. The rest of the links you've given seem to be "local development / getting started" and don't cover security configurations

Similarly, you need SASL properties in your properties variable to connect to the actual broker, assuming that is not part of streams.properties file...

Confluent Cloud requires authentication, and the values for that setting should be shown in your cluster dashboard.

If there were no authentication, anyone would be able to copy the code in your question and start sending/consuming random data ;)

kafka流avro消费者无法检索ID 10007的Avro模式

傾旎 2025-02-18 03:07:05

您仍然在“ C”样式阵列方面思考太多。
您可能想浏览 https://www.learncpp.com/ 学习一种更现代的方法C ++。
通过这种方法,您的代码看起来更像是这样:

#include <stdexcept>
#include <iostream>
#include <vector>
#include <string>

// use std::vector instead of "C" style arrays, they keep track of memory managment AND size of the arrays
// the const's ensure the function cannot modify the input arrays
// the reference (&) ensures the input arrays are not copied.

std::vector<std::string> merge(const std::vector<char>& char_values, const std::vector<int>& int_values)
{
    // check your input, merging doesn't make sense if arrays are not of the same length
    if (int_values.size() != char_values.size()) throw std::invalid_argument("arrays do not have equal size");
    
    std::vector<std::string> merged_array;
    merged_array.reserve(int_values.size());
    
    // use cbegin instead of begin
    // these iterators should constant to not change the input arrays
    auto int_it = int_values.cbegin();
    auto char_it = char_values.cbegin();
    
    for (; int_it != int_values.cend(); ++int_it, ++char_it)
    {
        // *char_it is the character
        // std::to_string converts integer to std::string
        // the + operator merges them togehter 
        // the result is a temporary std::string (not visible to you)
         // emplace_back can efficiently put this temporary into the vector
        merged_array.emplace_back(*char_it + std::to_string(*int_it));
    }

    // by using std::vector you also don't have to use a 3rd char** argument
    // making it much more clear who owns the memory
    // and you can just return an object!
    return merged_array;
}

int main()
{
    std::vector<char> char_values{ 'a', 'b', 'c' };
    std::vector<int> int_values{ 1,2,3 };

    auto merged_values = merge(char_values, int_values);

    // range based for loops are a safe way to loop over vectors
    for (const auto& value : merged_values)
    {
        std::cout << value << "\n";
    }

    return 0;
}

You're still thinking too much in terms of "C" style arrays.
You might want to go over https://www.learncpp.com/ to learn a more contemporary approach to C++.
With such an approach your code would look more like this:

#include <stdexcept>
#include <iostream>
#include <vector>
#include <string>

// use std::vector instead of "C" style arrays, they keep track of memory managment AND size of the arrays
// the const's ensure the function cannot modify the input arrays
// the reference (&) ensures the input arrays are not copied.

std::vector<std::string> merge(const std::vector<char>& char_values, const std::vector<int>& int_values)
{
    // check your input, merging doesn't make sense if arrays are not of the same length
    if (int_values.size() != char_values.size()) throw std::invalid_argument("arrays do not have equal size");
    
    std::vector<std::string> merged_array;
    merged_array.reserve(int_values.size());
    
    // use cbegin instead of begin
    // these iterators should constant to not change the input arrays
    auto int_it = int_values.cbegin();
    auto char_it = char_values.cbegin();
    
    for (; int_it != int_values.cend(); ++int_it, ++char_it)
    {
        // *char_it is the character
        // std::to_string converts integer to std::string
        // the + operator merges them togehter 
        // the result is a temporary std::string (not visible to you)
         // emplace_back can efficiently put this temporary into the vector
        merged_array.emplace_back(*char_it + std::to_string(*int_it));
    }

    // by using std::vector you also don't have to use a 3rd char** argument
    // making it much more clear who owns the memory
    // and you can just return an object!
    return merged_array;
}

int main()
{
    std::vector<char> char_values{ 'a', 'b', 'c' };
    std::vector<int> int_values{ 1,2,3 };

    auto merged_values = merge(char_values, int_values);

    // range based for loops are a safe way to loop over vectors
    for (const auto& value : merged_values)
    {
        std::cout << value << "\n";
    }

    return 0;
}

在C&#x2B;&#x2b;中合并int和char数组

傾旎 2025-02-18 02:31:16

可以使用 AnchorPreference 以一种更轻松的方式来完成此操作,那么您只需要一个偏好,并且无需使用 coordinatespace

我已经更新了您的代码以使用此信息。它解决了您所遇到的问题,只需注意,它不会将当前滚动到旋转时滚动的项目重新中心,但是如果由于旋转而更改,它确实会更改选择。

struct ContentView: View {
    
    // MARK: - Private Vars
    
    @State private var selectedNumber = 0
    
    private let rectangleHeight: [CGFloat] = [
        CGFloat.random(in: 500..<2000),
        CGFloat.random(in: 500..<2000),
        CGFloat.random(in: 500..<2000),
        CGFloat.random(in: 500..<2000),
        CGFloat.random(in: 500..<2000)
    ]
    
    private let colors: [Color] = [
        .blue,
        .red,
        .green,
        .gray,
        .purple
    ]
    
    // MARK: - View
    
    var body: some View {
        ScrollViewReader { reader in
            ScrollView(.horizontal) {
                HStack {
                    ForEach(0..<5) { index in
                        item(atIndex: index)
                    }
                }
            }
            .overlayPreferenceValue(ItemLeadingPreferenceKey.self) { anchors in
                GeometryReader { proxy in
                    // Find the index of the last anchor for which the x value is <= 0
                    // (indicating that it scrolled passed the beginning of the view)
                    let index = anchors.lastIndex(where: { proxy[$0].x <= 0 }) ?? 0

                    // Use this index to update the selected number
                    Color.clear
                        .onAppear {
                            selectedNumber = index
                        }
                        .onChange(of: index) {
                            selectedNumber = $0
                        }
                }
                .ignoresSafeArea()
            }
            
            footer(for: reader)
        }
    }
    
    // MARK: - Utils
    
    @ViewBuilder
    private func item(atIndex index: Int) -> some View {
        Rectangle()
            .fill(colors[index])
            .frame(width: rectangleHeight[index], height: 200)
            .id(index)
            .background {
                GeometryReader { proxy in
                    // Use the leading of this view for offset calculation
                    // You can also use center if that makes more sense for selection determination
                    Color.clear
                        .anchorPreference(key: ItemLeadingPreferenceKey.self, value: .leading) { [$0] }
                }
            }
    }
    
    @ViewBuilder
    private func footer(for proxy: ScrollViewProxy) -> some View {
        HStack {
            ForEach(0..<5) { index in
                ZStack {
                    if index == selectedNumber {
                        Rectangle()
                            .frame(width: 30, height: 30)
                    }
                    Rectangle()
                        .fill(colors[index])
                        .frame(width: 25, height: 25)
                        .onTapGesture {
                            withAnimation {
                                proxy.scrollTo(index, anchor: .leading)
                            }
                        }
                }
            }
        }
    }
}

struct ItemLeadingPreferenceKey: PreferenceKey {
    static let defaultValue: [Anchor<CGPoint>] = []
    
    static func reduce(value: inout [Anchor<CGPoint>], nextValue: () -> [Anchor<CGPoint>]) {
        value.append(contentsOf: nextValue())
    }
}

This can be done in a much easier way using anchorPreference, then you only need one preference and there is no need to use a coordinateSpace.

I've updated your code to use this instead. It solves the issue you are having, just note that it will not re-center the currently scrolled to item on rotation, but it does change the selection if it changed because of rotation.

struct ContentView: View {
    
    // MARK: - Private Vars
    
    @State private var selectedNumber = 0
    
    private let rectangleHeight: [CGFloat] = [
        CGFloat.random(in: 500..<2000),
        CGFloat.random(in: 500..<2000),
        CGFloat.random(in: 500..<2000),
        CGFloat.random(in: 500..<2000),
        CGFloat.random(in: 500..<2000)
    ]
    
    private let colors: [Color] = [
        .blue,
        .red,
        .green,
        .gray,
        .purple
    ]
    
    // MARK: - View
    
    var body: some View {
        ScrollViewReader { reader in
            ScrollView(.horizontal) {
                HStack {
                    ForEach(0..<5) { index in
                        item(atIndex: index)
                    }
                }
            }
            .overlayPreferenceValue(ItemLeadingPreferenceKey.self) { anchors in
                GeometryReader { proxy in
                    // Find the index of the last anchor for which the x value is <= 0
                    // (indicating that it scrolled passed the beginning of the view)
                    let index = anchors.lastIndex(where: { proxy[$0].x <= 0 }) ?? 0

                    // Use this index to update the selected number
                    Color.clear
                        .onAppear {
                            selectedNumber = index
                        }
                        .onChange(of: index) {
                            selectedNumber = $0
                        }
                }
                .ignoresSafeArea()
            }
            
            footer(for: reader)
        }
    }
    
    // MARK: - Utils
    
    @ViewBuilder
    private func item(atIndex index: Int) -> some View {
        Rectangle()
            .fill(colors[index])
            .frame(width: rectangleHeight[index], height: 200)
            .id(index)
            .background {
                GeometryReader { proxy in
                    // Use the leading of this view for offset calculation
                    // You can also use center if that makes more sense for selection determination
                    Color.clear
                        .anchorPreference(key: ItemLeadingPreferenceKey.self, value: .leading) { [$0] }
                }
            }
    }
    
    @ViewBuilder
    private func footer(for proxy: ScrollViewProxy) -> some View {
        HStack {
            ForEach(0..<5) { index in
                ZStack {
                    if index == selectedNumber {
                        Rectangle()
                            .frame(width: 30, height: 30)
                    }
                    Rectangle()
                        .fill(colors[index])
                        .frame(width: 25, height: 25)
                        .onTapGesture {
                            withAnimation {
                                proxy.scrollTo(index, anchor: .leading)
                            }
                        }
                }
            }
        }
    }
}

struct ItemLeadingPreferenceKey: PreferenceKey {
    static let defaultValue: [Anchor<CGPoint>] = []
    
    static func reduce(value: inout [Anchor<CGPoint>], nextValue: () -> [Anchor<CGPoint>]) {
        value.append(contentsOf: nextValue())
    }
}

当用户更改方向时,我如何从0开始重新计算yoffset

傾旎 2025-02-17 21:26:35

当Guillaume Blaquiere提到现在是不可能的。

当将API网关与云运行一起使用时,不可能仅允许从云运行中进行内部流量,以便仅允许云运行的VPC网络中的流量,这是此设置的唯一可用选项。

云运行服务设置为内部的入学流量无法接受API网关的请求,API网关在路线图上没有任何将流量标记为“内部”到无服务器后端的任何内容。

由于有功能请求支持更新Ingress设置以包括在内来自API网关的内部流量和Intress Internal,您将拥有一个“私人” IP供您服务。

Answering this as community wiki.As guillaume blaquiere mentioned it is not possible for now.

When using API Gateway with Cloud Run, it should not be possible to allow only internal traffic from Cloud Run in order to only allow traffic from within Cloud Run’s VPC Network,all ingress which is the only option available for this setup.

Cloud Run service with ingress traffic set to Internal could not accept requests from API Gateway, API Gateway does not have anything on the roadmap for marking traffic as "internal" to serverless backends.

This may be available in future since there is a Feature Request to support updating the ingress settings to include the option of internal traffic from API Gateway and with the ingress Internal you will have a "private" IP for your service.

Google Cloud API网关和云在私有上下文中运行

傾旎 2025-02-17 17:06:11

打开开发人员工具并执行以下行:

String.prototype.match = ()=>true
window.onbeforeunload = function(e) {return "Do you want to exit this page?";}

之后永远不会失败,ARN验证

Open the developer tools, and execute these lines:

String.prototype.match = ()=>true
window.onbeforeunload = function(e) {return "Do you want to exit this page?";}

After that if will never fail the ARN validation

资源字段无效。您必须输入有效的ARN

傾旎 2025-02-17 16:49:56

您正在尝试无需使用PHP包装即可直接在命令行上执行PHP,因此Bash Shell试图执行它并且无法识别PHP功能。

您需要在PHP文件中运行 shell_exec()或使用适当的PHP CLI语法。例如,您可以将 -r 传递到 php 命令,该命令允许您运行代码。

myusername:~$ php -r 'echo shell_exec("pwd");'
/home/myusername
myusername:~$ 

或者,您可以使用内置的替补。

myusername:~$ php -a
Interactive shell

php > echo shell_exec('pwd');
/home/myusername
php > 

另请注意,此处的使用 Echo ,因为成功的结果将返回我们想要看到的字符串。

You're trying to execute PHP directly on the command line without using the PHP packaging, so the bash shell is attempting to execute it and doesn't recognize the PHP function.

You need to run shell_exec() in a PHP file or use the appropriate PHP CLI syntax. For example, you can pass -r to the php command, which allows you to run code.

myusername:~$ php -r 'echo shell_exec("pwd");'
/home/myusername
myusername:~$ 

Or you can use the built-in REPL.

myusername:~$ php -a
Interactive shell

php > echo shell_exec('pwd');
/home/myusername
php > 

Also note the use of echo here since the successful result will return a string that we want to see.

-bash:shell_exec:找不到命令,shell_exec未在linux终端上运行

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文