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 6012289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:22:56+00:00 2026-05-23T02:22:56+00:00

I see myself doing the following code for default assigment all the type on

  • 0

I see myself doing the following code for default assigment all the type on PHP

$variable = $variable ? $variable : 'default value';

I know that with 5.3 I can do

$variable = $variable ?: 'default value';

I would like to further simplify it by being able to just do

$variable ?= 'default value';

and have the variable reassigned in case it evaluates to false. Is it possible to create that assignment? Do I have to compile my own version of php to do that?

  • 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-23T02:22:56+00:00Added an answer on May 23, 2026 at 2:22 am

    You cannot create new operators in PHP without changing the PHP source.

    And you don’t want to change it, trust me. Sure, it’d be easy enough – PHP is open source and uses a straightforward LALR(1) parser which you could easily modify – but that would make your code incompatible with the standard PHP implementation. You would thus very much restrict who can run the code – which will probably be nobody apart from you, as nobody else will care to modify their PHP engine just to run your code.

    Update: I wrote a small tutorial on how to add new syntax (like operators) to PHP: https://www.npopov.com/2012/07/27/How-to-add-new-syntactic-features-to-PHP.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see in a header that I didn't write myself the following: class MonitorObjectString:
I find myself doing the following a lot: C:\Code>hg pull pulling from http://server/FogBugz/kiln/Repo/Project/Rebuild/trunk searching
I am a web freelancer and had been doing all coding by myself using
I'm having a pretty weird problem with PHP and MySQL. I'm doing the following
I know that I can run specific migrations : rake db:migrate:up VERSION=20080906120000 But can
For example, i see myself doing things like this latley, when i create an
I see the word thrown around often, and I may have used it myself
I'm familiarizing myself with Ruby and it's the first time I see synonyms for
Edit: I have solved this by myself. See my answer below I have set
See code: var file1 = 50.xsl; var file2 = 30.doc; getFileExtension(file1); //returns xsl getFileExtension(file2);

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.