PHP Depraction function

We moved our shopping cart from one vendor to another.  The new vendor is using a newer version of php.  I was getting a Deprecated: Function ereg() is deprecated in C:\inetpub... on line...
for the first of these three lines

      ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev);
            $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
      }

I changed the lines to the following:

      preg_match('/$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
            $this->setHeader('User-Agent', $this->title.'/'.$this->version.' (/'.$rev[#].'/)');
      }

I am now getting the following error:

Parse error: syntax error, unexpected '}', expecting ']' in C:\inetpub\... on line 2162

I tried changing the } to ] but then I just get a different error telling me that's not acceptable.  
PDISAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Is $Reviso a variable in your code?
0
käµfm³d 👽Commented:
Also, why do you have a '}' at the end of that block of code? Where is the opening '{'?
0
Terry WoodsIT GuruCommented:
     ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev);
            $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
      }

should be the same as:
      ereg('\$Revision: ([^ ]+)', $this->revision, $rev);
            $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
      }

which should be equivalent to:
      preg_match('/\$Revision: ([^ ]+)/', $this->revision, $rev);
            $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
      }

$rev[1] is simply the 1st array value of the $rev array, which remains the same for ereg and preg_match. $rev[0] is defined for preg_match, but not for ereg, but since we aren't using it here it doesn't matter. The $ in $Revision shouldn't need to be escaped with a backslash in this case, but it's clearer for anyone maintaining it if it is.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.