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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:49:25+00:00 2026-05-26T01:49:25+00:00

In the latest phpmailer example file, there’s the following line: $body = eregi_replace([\],”,$body); As

  • 0

In the latest phpmailer example file, there’s the following line:

$body = eregi_replace("[\]",'',$body);

As I’m not really good in regular expressions, I can’t figure out what the above does and whether I need to use it when I write my own block of data ($body). Could anyone help me figure this out?

EDIT

I really copied it properly. Here is a whole chunk of code from the original phpmailer example file, completely untouched:

require_once('../class.phpmailer.php');

$mail             = new PHPMailer(); // defaults to using php "mail()"

$body             = file_get_contents('contents.html');
$body             = eregi_replace("[\]",'',$body);

$mail->AddReplyTo("name@yourdomain.com","First Last");

$mail->SetFrom('name@yourdomain.com', 'First Last');
  • 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-26T01:49:25+00:00Added an answer on May 26, 2026 at 1:49 am

    That code is removing all backslashes from $body.

    Though it may look a little odd at first glance, the regex is correct. The backslash isn’t a metacharacter when it’s inside brackets in a POSIX regex.

    There’s all sorts of problems with this code anyway, though, especially since it’s supposed to be an example:

    • It uses one of the deprecated ereg (or POSIX) family of regex functions. Half-recent PHP examples should pretty much all be using the preg (Perl-compatible) family instead.
    • It uses case-insensitive matching (the i in eregi) even though it’s not matching against any letters, so case is irrelevant.
    • Most importantly, the actual purpose of the replacement is unclear. I can only guess that this is a misguided attempt to account for PHP’s magic quotes feature that automatically adds backslashes to all sorts of things.

      To be clear, this code is not a proper way to deal with magic quotes, since it will remove all backslashes from $body, even “real” ones present in the original input. The stripslashes() function is intended for exactly this use case. Or, since the example deals with reading from a file, you could simply turn off magic quotes.

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

Sidebar

Related Questions

I have the latest versions of Firefox and IE, but the example in html5rocks.com
The latest version of the Entity Framework got me in love, still at good
The latest version of Apple's UICatalog example application includes zero code in the TextFieldController
I have been trying to get the latest version of phpmailer from here: http://sourceforge.net/projects/phpmailer/files/
latest Fp 11.1.102.55 Firefox v 3.5.2 OSX My rollover events are not firing. Every
The latest version of XCode supports reference counting. However many older libraries are not
Running latest release of jQuery Mobile (1.0.1), and do not want to use AJAX
My latest Twitter status update has the URL http://twitter.com/dinomite/status/1743967905 Does anyone know if there
I am using latest Jquery and the following script: <script type=text/javascript> $(document).ready(function(){ var el
Latest version of both, can not see how to enable ActiveMQ as an endpoint

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.