Wednesday, June 16, 2010

Segmentation fault when accessing a PHP page

Sometimes when one of our Apache web servers is restarted, we experience segmentation faults when any PHP page is subsequently accessed. The following line is printed in the httpd error_log:

[Wed Jun 16 10:59:33 2010] [notice] child pid 31513 exit signal Segmentation fault (11)

There will be one of these lines for each PHP page that is accessed. This appears to happen randomly - the "workaround" to-date is to restart httpd, which eventually fixes the problem (almost always after a single restart). Although we only see this happen rarely, it still happens frequently enough to be of concern.

So my question is, why is this happening in the first place? Is this a known bug with the version of Apache / PHP / Linux / etc that we are using? Any ideas?

The environment is:

  • Fedora 11
  • Apache 2.2.15 (Default settings)
  • PHP 5.2.13

I can provide more information if that would help narrow things down, since this error message is rather generic...

Any help is appreciated.

When it is necessary to use Classes in PHP

Hello,

I am a wordpress plugin developer. I saw the source of many pluginsand many plugin use "classes" in them and some without classes.

Many huge coded plugins like "wp-postratings" does not use Classes and some small plugins use Classes.

edit: Since classes have private, public and protected access specifiers, i feel a taste of security Does it increase security?

Other than PHP does other languages require classes ?

Is it compulsory to use Classes ?

I need some suggestions.

Get reply mail to my server for a mail sent through php mail function

Hi, I am developing a system to send mail to all of our clients. If they reply to that mail, I want to retrieve the reply mails to my server. There is a way to connect through the IMAP/POP3 server, But it is taking a long time to load the mails. Is there any way to get the reply mails directly to my server. or ay other alternate way to get the mails fastly through IMAP

Please Help me in solving this issue

How to Send Email from a PHP Script

All it takes is the right configuration (to send mail using a local or a remote server) and one function:

  • mail().

Send Email from a PHP Script Example

The first argument to this function is the recipient, the second specifies the message's subject and the third one should contain the body. So to send a simple sample message, we could use:

<?php
$to = "recipient@example.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("

Message successfully sent!

");
} else {
echo("

Message delivery failed...

");
}
?>

That's it!

Use Custom Headers (e.g. "From:") in Mail from a PHP Script

Do you want to set a custom From: address, maybe taken from the form you send, or another custom header line? It is but an additional argument you need.

Protecting Your Script from Spammer Exploit

If you use the mail() function (in combination with a web form in particular), make sure you check it is called from the desired page and protect the form with a CAPTCHA maybe. You can also check for suspicious strings in any arguments (say, "Bcc:" followed by a number of email addresses).

Send Email from a PHP Script with SMTP Authentication

If mail() does not work for you, you have options, too. The mail() function included with stock PHP does not support SMTP authentication, for example. If mail() does not work for you for this or another reason, try the PEAR Mail package, which is much more comprehensive and sending mail almost as easily from your PHP scripts.

What is PHP?

PHP (recursive acronym for "PHP: Hypertext Preprocessor") is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

Notice how this is different from a script written in other languages like Perl or C -- instead of writing a program with lots of commands to output HTML, you write an HTML script with some embedded code to do something (in this case, output some text). The PHP code is enclosed in special start and end tags that allow you to jump into and out of "PHP mode".

What distinguishes PHP from something like client-side JavaScript is that the code is executed on the server. If you were to have a script similar to the above on your server, the client would receive the results of running that script, with no way of determining what the underlying code may be. You can even configure your web server to process all your HTML files with PHP, and then there's really no way that users can tell what you have up your sleeve.

The best things in using PHP are that it is extremely simple for a newcomer, but offers many advanced features for a professional programmer. Don't be afraid reading the long list of PHP's features. You can jump in, in a short time, and start writing simple scripts in a few hours.

Although PHP's development is focused on server-side scripting, you can do much more with it. Read on, and see more in the What can PHP do? section, or go right to the introductory tutorial if you are only interested in web programming.