如何在PHP中确保正整数值 [英] How to make sure a positive integer value in PHP

查看:289
本文介绍了如何在PHP中确保正整数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用变量$ pagenum,该变量通过GET方法获取?pageid值.我想确保此值必须为正整数值.我该怎么做?

I am using a variable $pagenum which gets the ?pageid value through GET method. I want to make sure that this value must be positive integer value. How can I do that?

推荐答案

pagenum,它通过GET方法获取?pageid值.我想确保此值必须为正整数值.我该怎么办?
pagenum which gets the ?pageid value through GET method. I want to make sure that this value must be positive integer value. How can I do that?


这里是伪代码:

1.检查您要分配的值
2.如果它为负(<0),请不要分配.
3.否则,分配它.

[更新]
我发现了此链接 [
Here''s a pseudocode:

1. Check the value that you want to assign
2. If it is negative(<0), dont assign.
3. Else, assign it.

[update]
I found this link[^]


这篇关于如何在PHP中确保正整数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆