note 74710 added to language.types.string

From: Date: Tue, 24 Apr 2007 17:14:28 +0000
Subject: note 74710 added to language.types.string
Groups: php.notes 
Request: Send a blank email to php-notes+get-125836@lists.php.net to get a copy of this message
error control operator (@) with heredoc syntax: the error control operator is pretty handy for supressing minimal errors or omissions. For example an email form that request some basic non mandatory information to your users. Some may complete the form, other may not. Lets say you don't want to tweak PHP for error levels and you just wish to create some basic template that will be emailed to the admin with the user information submitted. You manage to collect the user input in an array called $form: <?php // creating your mailer $mailer = new SomeMailerLib(); $mailer->from = ' System <mail@yourwebsite.com>'; $mailer->to = 'admin@yourwebsite.com'; $mailer->subject = 'New user request'; // you put the error control operator before the heredoc operator to suppress notices and warnings about unset indices like this $mailer->body = @<<<FORM Firstname = {$form['firstname']} Lastname = {$form['lastname']} Email = {$form['email']} Telephone = {$form['telephone']} Address = {$form['address']} FORM; ?> ---- Server IP: 216.235.15.211 Probable Submitter: 69.70.24.116 ---- Manual Page -- http://www.php.net/manual/en/language.types.string.php Edit -- https://master.php.net/note/edit/74710 Del: integrated -- https://master.php.net/note/delete/74710/integrated Del: useless -- https://master.php.net/note/delete/74710/useless Del: bad code -- https://master.php.net/note/delete/74710/bad+code Del: spam -- https://master.php.net/note/delete/74710/spam Del: non-english -- https://master.php.net/note/delete/74710/non-english Del: in docs -- https://master.php.net/note/delete/74710/in+docs Del: other reasons-- https://master.php.net/note/delete/74710 Reject -- https://master.php.net/note/reject/74710 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125836) next »