如何检查文本是否包含至少一个A到Z字母?(How can I check if the text contains at least one A to Z letter?)
我怎么能用PHP写这个?
if ($text contains at least one letter from A to Z, regardless of numbers or other characters) echo 'Yes'; else echo 'No';
请帮忙。
How can I write this in PHP?
if ($text contains at least one letter from A to Z, regardless of numbers or other characters) echo 'Yes'; else echo 'No';
Please help.
原文:https://stackoverflow.com/questions/7550323
最满意答案
我发现你的第一个论点完全似是而非。 不管你喜欢与否,参数的名称都是每个方法语义的一部分,特别是对于将在子类中重写的抽象类和方法。 参数的名称是关于该方法的语义的方法的用户以及该语义中的每个参数角色的关键信号。 此外,理解整个类层次结构中的语义是必不可少的,参数名称必须一致,并且不受每个级别的各个程序员的突发奇想的影响。
我发现你的第二个论点完全无法理解。 如果你在这里确实有一个有效点,我建议你重写一下以获得更大的清晰度。
也就是说,我很少在我的方法调用中使用命名参数; 例外情况是接受两个以上相同类型的连续参数的方法。 在这种情况下,我喜欢命名它们,以便作为代码的未来读者,我实际上可以破译方法的使用,而不必经常盘旋以观察智能。
I find your first argument completely specious. Like it or not the names of parameters are part of each method's semantics, particularly for abstract classes and methods that will be overridden in subclasses. The names of the parameters are a key signalling to users of a method on the semantics of that method, and of each parameters role in that semantics. Further it is essential for understanding of the semantics throughout the class hierarchy that parameter names be consistent, and not subject to the whims of individual programmers at each level.
Your second argument I find completely unintelligible. If you actually have a valid point here I suggest you rewrite this to achieve greater clarity.
That said, I rarely use named parameters in my method calls; the exception being for methods that accept more than two consecutive parameters of the same type. In this case I like to name them so that I, as the future reader of the code, can in fact decipher the method's use without having to constantly hover to see the intelli-sense.
相关问答
更多-
为什么不报告实际的错误? 不,这是问题所在; 它报告了实际的错误。 让我用一个稍微复杂的例子来解释一下。 假设你有这个: class CustomerCollection { public IEnumerable
Select (Func projection) {...} } .... customers.Select( (Customer c)=>c.FristNmae ); 好的, 根据C#规范 ,错误是什么? 你必须在这里仔细阅读说明书。 让我们解决它。 ... -
文档注释在C#中:什么是技术原因更喜欢///或/ **(Documentation comments in C#: What are technical reasons to prefer /// or /**)[2022-10-13]
Info自发布此问题以来,我已经能够收集信息,证实即使csc /doc:将接受任一格式,但单行格式与多行格式相比具有一些优势: 1)在Visual Studio中,无论您最初是使用///或/ **记录您的方法,IntelliSense都会为您提供信息,说明您在输入时在方法调用表达式中传递的参数。 但是,只有在使用///格式时,Visual Studio才会为使用预填写的文档注释提供支持。 例如,如果将光标放在Visual Studio中的方法声明上方,然后按/三次,则会看到为您生成的特定于上下文的模板,如下 ... -
如果您有一个定义可选参数的C#库,那么您可以使用您在问题中使用的语法。 为了快速显示这种情况,我将以下C#代码编译为库: using System; namespace Demo { public class MyClass { public static void Foo(int first, string second = "foo", string third = "bar") { } } } 您可以引用它并从F#中使用它,如下所示: open Demo MyClass.Foo(1 ...
-
我发现你的第一个论点完全似是而非。 不管你喜欢与否,参数的名称都是每个方法语义的一部分,特别是对于将在子类中重写的抽象类和方法。 参数的名称是关于该方法的语义的方法的用户以及该语义中的每个参数角色的关键信号。 此外,理解整个类层次结构中的语义是必不可少的,参数名称必须一致,并且不受每个级别的各个程序员的突发奇想的影响。 我发现你的第二个论点完全无法理解。 如果你在这里确实有一个有效点,我建议你重写一下以获得更大的清晰度。 也就是说,我很少在我的方法调用中使用命名参数; 例外情况是接受两个以上相同类型的连续参 ...
-
使用C ++ / CLI的唯一原因是您可以在托管应用程序中使用本机库。 即使微软说它不应该单独使用它: 使用C ++ / CLI的第二个主要考虑是要记住,这只是在托管和本地世界之间架起一座桥梁,而不是用来编写大部分应用程序的技术。 这样做肯定是可行的,但是您会发现开发人员的生产力远低于纯C ++或纯C#/ Visual Basic环境,并且您的应用程序运行起来要慢得多。 因此,当您使用C ++ / CLI时,只需使用/ clr开关编译所需的文件,并使用纯托管或纯原生程序集的组合来构建应用程序的核心功能。 h ...
-
我可以传递任意数量的命名参数在C#中运行吗?(Can I pass arbitrary number of named parameters to function in C#?)[2022-12-20]
C#中没有任何东西可以让你传入像这样的任意命名参数。 你可以通过添加一个Dictionary参数来关闭它,它允许你做类似的事情,但需要一个构造函数,“参数名称”是字符串和一些额外的大括号: static void Method(int normalParam, Dictionary kwargs = null) { ... } Method(5, new Dictionary {{ "One", 1 }, ... -
在JavaScript中命名参数(Named arguments in JavaScript)[2022-01-30]
是的,传入一个对象文字 function myFunc(options) { if(options.a!=undefined) this.a = options.a; if(options.b!=undefined) this.b = options.b; if(options.c!=undefined) this.c = options.c; } 并像这样打电话 var var1 = new myFunc({b:"some value for b"}); 或者为了更加动态,可扩 ... -
在PHP中命名参数(Named Arguments in PHP)[2024-02-19]
正如您所知,PHP中不存在命名参数。 但是一种可能的解决方案是使用一个数组作为唯一参数 - 因为数组项可以命名为: my_function(array( 'my_param' => 10, 'other_param' => 'hello, world!', )); 并且,在您的函数中,您将从该唯一数组参数中读取数据: function my_function(array $params) { // test if $params['my_param'] is set ; an ... -
有点,有点复杂的文字和指定的初始值设定项: typedef struct foo_args { int a; int b; int c; } foo_args; // Later foo(&(foo_args) { .a = 2, .c = 3, .b = 1 }); 但我真的不会打扰。 它要求你弯曲函数定义来接受一个指针,并且调用它很麻烦。 Kinda, sorta, with a compound literal and designated initializers: t ...
-
在C ++中不允许多参数运算符[]的基本原因(Fundamental reasons for not allowing multi-arguments operator[] in C++)[2024-03-05]
这可能会被添加,但不应该 ,因为它会破坏现有的代码 。 基本上, operator[]多个参数意味着以下代码将被编译: struct Foo { int operator[](int a, int b, int c) { return 0; } } int main() { Foo foo; auto n = foo[1, 2, 3]; // list of parameters } 不过考虑一下: int main() { Foo foo ...