首页 \ 问答 \ 如何检查文本是否包含至少一个A到Z字母?(How can I check if the text contains at least one A to Z letter?)

如何检查文本是否包含至少一个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
更新时间:2022-03-06 08:03

最满意答案

我发现你的第一个论点完全似是而非。 不管你喜欢与否,参数的名称都是每个方法语义的一部分,特别是对于将在子类中重写的抽象类和方法。 参数的名称是关于该方法的语义的方法的用户以及该语义中的每个参数角色的关键信号。 此外,理解整个类层次结构中的语义是必不可少的,参数名称必须一致,并且不受每个级别的各个程序员的突发奇想的影响。

我发现你的第二个论点完全无法理解。 如果你在这里确实有一个有效点,我建议你重写一下以获得更大的清晰度。

也就是说,我很少在我的方法调用中使用命名参数; 例外情况是接受两个以上相同类型的连续参数的方法。 在这种情况下,我喜欢命名它们,以便作为代码的未来读者,我实际上可以破译方法的使用,而不必经常盘旋以观察智能。


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#规范 ,错误是什么? 你必须在这里仔细阅读说明书。 让我们解决它。 ...
  • 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#中没有任何东西可以让你传入像这样的任意命名参数。 你可以通过添加一个Dictionary参数来关闭它,它允许你做类似的事情,但需要一个构造函数,“参数名称”是字符串和一些额外的大括号: static void Method(int normalParam, Dictionary kwargs = null) { ... } Method(5, new Dictionary{{ "One", 1 }, ...
  • 是的,传入一个对象文字 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中不存在命名参数。 但是一种可能的解决方案是使用一个数组作为唯一参数 - 因为数组项可以命名为: 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 ...
  • 这可能会被添加,但不应该 ,因为它会破坏现有的代码 。 基本上, 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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)