PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 28th, 2000, 03:32 PM
ikaros ikaros is offline
PHP Programmer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 31 ikaros User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 43 sec
Reputation Power: 14
Send a message via ICQ to ikaros
Hi all,

I want to check if a string contains only alphabetical and/or numerical characters. I think the solution is eregi, but i am not an expert on regular expressions...

Help extremely appreciated!

Reply With Quote
  #2  
Old May 29th, 2000, 12:41 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan

You can find out whether the value is string or a numerical value using two functions.

is_string() and is_int();

is_string()->This will find out whether variable is a string.

is_int()->This will find out whether variable is an integer.


or

probably you may use gettype() function to find out variable type.

$type=gettype($value);

#this will return the type of the variable.



------------------
SR -
shiju.dreamcenter.net

"The fear of the LORD is the beginning of knowledge..."

Reply With Quote
  #3  
Old May 29th, 2000, 05:20 AM
ikaros ikaros is offline
PHP Programmer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 31 ikaros User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 43 sec
Reputation Power: 14
Send a message via ICQ to ikaros
Thats not what I meant... I want to make sure that a string contains ONLY a-z and 0-9, so that i can provide email-adress to my users.
I dont want users to hav signs like
" ' ! @ £ $ € [ ] { }
ans so on...

Reply With Quote
  #4  
Old May 29th, 2000, 07:01 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
ohh sorry,

you can use the ereg() for doing this.

if (!ereg('^[-!#$%&'*+./0-9=?A-Z^_`a-z{|}~]+', $value){
//This will check the email validity

------------------
SR -
shiju.dreamcenter.net

"The fear of the LORD is the beginning of knowledge..."

Reply With Quote
  #5  
Old May 30th, 2000, 03:21 AM
ikaros ikaros is offline
PHP Programmer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 31 ikaros User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 43 sec
Reputation Power: 14
Send a message via ICQ to ikaros
yeah, I know i can use ereg (or eregi), but how does regular expressions work? That's my question!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > string check

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap