char @ sembunyikan error php

setelah sekian waktu akhirnya sedikit paham makna tanda @ pada script fungsi php

<?php
 $ug = 'www.google.com';
 $uy = 'http://www.yahoo.com';

 $ag = parse_url($ug);
 $ay = parse_url($uy);

 echo ($ay['scheme'])?$ay['scheme']:'errrror';
 echo '<br />';
 echo ($ag['scheme'])?$ag['scheme']:'errrror';
?>

didapatkan warning = Notice: Undefined index: scheme in /media/drive_c/wamp/www/ip_trace/test.php on line 10

sementara jika menggunakan char @ didepan operasi fungsi yang mungkin menghasilkan tanda warning, warning tersebut tidak akan dimunculkan

<?php
 $ug = 'www.google.com';
 $uy = 'http://www.yahoo.com';

 $ag = parse_url($ug);
 $ay = parse_url($uy);

 echo ($ay['scheme'])?$ay['scheme']:'errrror';
 echo '<br />';
 echo (@$ag['scheme'])?$ag['scheme']:'errrror';
?>

Published by

G3n1k

just to remember what i had known :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s