首页 \ 问答 \ 在PHP中掩盖信用卡号码(Mask credit card number in PHP)

在PHP中掩盖信用卡号码(Mask credit card number in PHP)

我有我想要掩盖的信用卡号码,如下所示:

$cc = 1234123412341234

echo cc_masking($cc)

1234XXXXXXXX1234

function cc_masking($number) {.....}

请为此提出正则表达式。


I have credit card number which I want to mask as below:

$cc = 1234123412341234

echo cc_masking($cc)

1234XXXXXXXX1234

function cc_masking($number) {.....}

Please suggest the regular expression for this.


原文:https://stackoverflow.com/questions/13413886
更新时间:2022-08-16 08:08

最满意答案

如果我们的架构可能有任何设计缺陷。

好吧,请记住,从通用图表中我们无法说清楚。 但这里有一些注意事项:

1)MongoDB不像其他数据库(如DynamoDB,Riak或Cassandra)那样容易扩展。 例如,如果您超过单个主服务器的容量(无论您拥有多少个从属服务器,所有写入服务都转到单个主服务器),您将不得不进行分片。 但是切换到分片是非常具有破坏性的,并且设置起来非常繁琐。

如果你不希望超过一个节点的写入容量,那么你就可以在MongoDB上运行了。

2)您将如何处理异步任务,例如发送电子邮件,创建长报告等?

可以在请求循环中执行这些操作,这可能是一个很好的入门方法。 但是当你有更多的盒子时,失败的可能性就会增加。 当一个盒子死掉时,所有的异步任务都会消失,没有人会知道它们是什么。 你也可能遇到一个问题,即一个盒子负载过重的异步任务(使用太多的CPU或内存),并且问题会变得越来越糟,因为它会获得更多任务并且更慢地完成它们。

此外,像ELB这样的前端将有60秒的限制,如果您的某些请求可能需要更长时间,这可能会导致问题。 (通过轮询或其他东西将它们转移到异步作业中。)

3)ELB不支持Web套接字。 考虑一下,如果您认为自己可能需要使用websockets。


if our architecture might have any design flaws.

Well, keep in mind that we can't tell much from a generic diagram. But here are some notes:

1) MongoDB isn't as easy to scale as other databases such as DynamoDB, Riak or Cassandra. For example, if you ever exceed the capacity of a single master (no matter how many slaves you have, all writes go to the single master), you'll have to shard. But switching to sharding is very disruptive and very tedious to set up.

If you don't expect to exceed the write capacity of one node, then you'll be fine on MongoDB.

2) What will you do for async tasks such as sending emails, creating long reports, etc?

It's possible to do these things in the request loop, and that's probably a fine way to get started. But as you have more boxes, the chances of failure go up. When a box dies, all the async tasks go away and nobody will know what they were. You also can have problems where one box gets heavily loaded with async tasks (using too much CPU or memory), and the problem will get worse and worse as it gets more tasks and completes them more slowly.

Also, a front-end like ELB will have a 60-second limit, which can cause problems if some of your requests could take longer. (Spin them off into async jobs with polling or something.)

3) ELB doesn't support web sockets. Consider that if you think you might want websockets down the road.

相关问答

更多
  • 是的,这是一个众所周知的模式,用于处理Web应用程序后端的长期任务。 根据您的语言和应用程序框架,有许多队列实现 - 例如Resque , Beanstalkd或ActiveMQ,或者如果您的性能要求不高,可以使用数据库表作为一种队列。 基本思想是您的Web应用程序将作业放置在具有足够内容的队列中,以启用作业。 后台的一组工作进程(最好独立于Web应用程序运行)从队列中读取作业并执行它们。 结果可以写回到回复队列中,或写入数据库。 这取决于你想如何显示结果回给用户。 对于Web应用程序,将结果写入数据库可能 ...
  • 您将需要使用一组工具: Loadtesting工具 - 可以使用JMeter。 监控工具 - 此工具将用于监控各种数量的资源负载。 有很多付费以及免费的。 Jprofiler,visualvm等 收集和报告工具。 (没有使用任何工具) 使用上述工具,您可以找到最佳值。 我会按照以下方式处理它。 将会知道应该访问哪些页面的比例。 什么是后台进程及其频率。 相应地配置我的JMeter(针对比率),并监视所用负载的性能(服务页面的时间...可以在JMeter中完成),使用Monitor工具监视其他资源。 还要检查 ...
  • 使用heroku和美洲狮。 这是最容易设置的。 http://www.justinweiss.com/articles/a-web-server-vs-an-app-server/ https://www.nateberkopec.com/2015/07/29/scaling-ruby-apps-to- 1000-rpm.html https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-serv ...
  • 不幸的是,您的问题有很多方面会依赖于上下文。 根据您的要求和应用程序,可伸缩性可能意味着不同的东西。 在您提出架构时需要回答的问题(无论您使用何种技术)包括: 例如,您是否希望支持使用大量数据的用户,或者您是否只需要支持大量用户,每个用户使用相对适量的数据? 你的应用程序是否比写入更多的读取,因为读取是便宜的,并且写入是昂贵的,读取繁重的应用程序可以比写入重的应用程序更容易扩展。 您的应用程序中的数据是否始终一致或最终的一致性是否足够? 考虑向社交网站发布消息而不是从银行账户中提取资金)。 您的申请需要多少 ...
  • “实时”动作或应用程序或系统具有及时性和可预测性约束。 原则上,这与系统架构无关 - 在实践中,架构必须适合您需要的实时属性。 发布/订阅机制具有基于从可发布事件发生到事件在所有运营订户中显示的延迟的实时度量 - 简化,实时=真实快速(想想自动化金融交易)。 但实时性与时效性可预测性同样重要。 在P / S案例中,感兴趣的可预测性是延迟 - 在幅度和可变性方面(“抖动”是一种特殊情况)。 在研究和从业者社区中有很多文献 - 在你的情况下,我建议阅读RTI网站上的一些优秀文件(尽管IMHO RTI并没有尽可能 ...
  • 老实说,大多数“Web应用程序”可能都是用PHP编写的。 无论如何阅读web框架,但是为了让你从这里开始是一个最广泛使用的Web框架列表(我能想到)。 Ruby : Rails Python : Django Java : Spring C# : ASP.NET MVC 然后有专门的东西,如Google Web Toolkit用于编写类似应用程序的Gmail。 我个人倾向于ASP.NET MVC和Django,但Rails和Spring也很不错。 但是,对于许多这样的应用程序而言,不仅仅是Web框架。 大 ...
  • 如果我们的架构可能有任何设计缺陷。 好吧,请记住,从通用图表中我们无法说清楚。 但这里有一些注意事项: 1)MongoDB不像其他数据库(如DynamoDB,Riak或Cassandra)那样容易扩展。 例如,如果您超过单个主服务器的容量(无论您拥有多少个从属服务器,所有写入服务都转到单个主服务器),您将不得不进行分片。 但是切换到分片是非常具有破坏性的,并且设置起来非常繁琐。 如果你不希望超过一个节点的写入容量,那么你就可以在MongoDB上运行了。 2)您将如何处理异步任务,例如发送电子邮件,创建长报告 ...
  • 我认为你有错误的方法,而不是使用热备用,你应该使用负载平衡和群集来提供可用性。 我的建议是在两台服务器上运行Web应用程序,并使用IP Load Balancer在两台服务器之间分配请求。 如果其中一个服务器不可用,用户请求将不再路由到该服务器,用户将不会真正注意到已发生中断。 您应该尝试在公司基础架构中使用现有的负载均衡器。 如果您有两台以上的服务器,我还建议您查看Windows网络负载平衡(NLB),其中包含Windows Server中的一项功能,请访问http://technet.microsoft ...
  • 这是我的答案: 2)GET和POST都可以根据你正在做的事情使用,通常GET用于简单地获取信息,比如提取用户的信息,POST通常用于发送信息,基本上只是提供表单提交数据的任何内容。 3)为了帮助提高安全性,您可以添加另一个GET变量,然后在您的php中,您可以做的第一件事是查看该变量是否设置为正确的值。 如果不是只是杀死脚本。 这样,如果有人偶然浏览'yourdomain.com/create-user.php'它将无效,他们需要浏览'yourdomain.com/create-user.php?appke ...

相关文章

更多

最新问答

更多
  • 您如何使用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)