Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 694145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:49:36+00:00 2026-05-14T02:49:36+00:00

I am using PHP’s magic __set and __get methods to access a private array

  • 0

I am using PHP’s magic __set and __get methods to access a private array in a class. Use of the class can include “setting” new properties as well as using existing ones. I want to make sure the property names created or requested (i.e. $myObj->FakeProperty) are valid according to the following rules:

  1. Property names must begin with either a letter or underscore [A-z_]
  2. If it begins with an underscore, it must be followed by a letter
  3. So long as the first two rules are met, the name may contain any of [A-z0-9_]

My current RegEx isn’t doing the trick; with my test values, _12 always falls through the cracks.

Test Fields:

albert12
12Albert
_12
_Albert12
_12Albert
_____a_1

RegEx:

^(?=_*[A-z]+)[A-z0-9_]+$
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:49:36+00:00Added an answer on May 14, 2026 at 2:49 am

    according to docs, the following would match any valid php identifier

    /^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PHP's Image and GD functions you can use the following method to finally
Using PHP on Linux, I can just use the is_link() function to detect whether
Using PHP, I can convert MySQL data or static table data to csv, Excel,
Using PHP ... This is for my personal use so I'm thinking maybe 3-4
Using PHP I need I will have an array of tag name => tag
Using PHP, can I post content to a Facebook page when I add something
Using php-sdk I obtain pages in this way: $array = $this->instance->api( '/' . $fb_user
Using PHP's ReflectionClass. Is this possible? I want to get a list of methods
Using PHP, If I have a model (a class) where I various queries, whatever
Using PHP's proc_open() , I can start a process, read from STDOUT and STDERR

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.