« first day (273 days earlier)      last day (4899 days later) » 

05:37
anyone here
 
1 hour later…
06:38
yes, i am there
happy weekend to all
 
3 hours later…
09:48
posted on July 16, 2011 by Fabien Potencier

People like micro-optimizations. They are easy to understand, easy to apply... and useless. But some time ago, while reviewing pull requests for Twig, I read an interesting discussion about the performance of the ternary operator in PHP (thanks to @nikic for the investigation). Do you know which following snippet is the fastest (of course, they do exactly the same)? // snippet 1 $tmp =

 
2 hours later…
11:53
print "<td>" if ($quality=="3") echo "SD" "</td>"; How do I get that to work?
12:16
@Michael what is the problem?
@Gordon I'm getting an unexpected T_IF error
well, obviously. that line is full of syntax errors
Yes I know.. Looking for help correcting them
expressions/statements/language constructs have to be ended with ;
if clauses are easier to grasp if you put the code block that should be evaluated when the condition is true into curly brace and on new lines
and the corresponding manual pages for print and echo
and also consider adopting the pear.php.net/manual/en/standards.php coding standard
hey
hey
13:10
hey folks, have you ever worked with xml SimpleXMLElement
@hey yes
hey
hey
let's say its <media>text</media>, I retrieve text by writting this code: $xml = new SimpleXMLElement($url); echo $xml->media[0];
and if it's <media:something>text</media>
how do I retrieve text then?
do you know what the : between media and something means?
hey
hey
not really
it means its a namespaced element
hey
hey
13:12
<media:thumbnail url="some_url" />
is it possible to retrieve some_url?
sigh
1
A: Read a namespaced attribute from a SimpleXmlElement (imported from XMLReader)

GordonAttributes with colons in their name have a namespace. The part before the colon is a prefix that is registered to some namespace (usually in the root node). To access the namespaced attributes of a SimpleXmlElement you have to pass the namespace to the attributes() method: $attributes = $elem...

if you seriously work with XML, you have to understand namespaces. there is no way around it
hey
hey
I just want to create simple app for myself and just started to read php manual on simplexml
yeah, no problem.. its just that this question about media:thumbnails gets asked over and over again because people dont understand namespaces
XML namespaces are used for providing uniquely named elements and attributes in an XML document. They are defined in a W3C recommendation. An XML instance may contain element or attribute names from more than one XML vocabulary. If each vocabulary is given a namespace, the ambiguity between identically named elements or attributes can be resolved. A simple example would be to consider an XML instance that contained references to a customer and an ordered product. Both the customer element and the product element could have a child element named id. References to the id element would theref...
hey
hey
finally :)
did it
had to write this though: $feed = str_replace('<media:thumbnail', '<thumbnail', $feed);
funny
hey
hey
13:33
is it possible to check whether <media:thumbnail exists or no?
if(!empty($xml->attributes()->url)) doesn't work
if it's empty, I get this error
Warning: main() [function.main]: Node no longer exists in
@Gordon
@hey i linked you to all the answers you need already.
13:49
posted on July 16, 2011 by Pádraic Brady

Image via Wikipedia When we use the term PHP, we are often silently associating it with the abbreviation LAMP (that’s Linux, Apache, MySQL and PHP just in case you don’t recall). MySQL has been our bread and butter in PHP for over a decade; an old friend, accomplice and partner in crime. This was made possible with the MySQL extension. Indeed, you can scarcely find a basic nut

hey
hey
14:01
@Gordon: is it expensive every page to use file_get_contents and get xml from page?
or should I definitely use cache?
14:25
@hey you dont use file_get_contents to fetch xml from pages. you can do that with simplexml. if you know the xml isnt going to change often, then using a cache would likely be smarter
hey
hey
ok, ty
 
1 hour later…
15:29
Good Morning/Afternoon
16:12
good afternoon @ircmaxell et al.
user1385191
quick question regarding OOP
user1385191
is there a convention to naming class files ".class.php", or is it required?
it's not required and afaik it's not the most common convention
16:47
guys
any one here
@MattMcDonald , actually people usually use ClassName.php , and the folder structure mirrors the structure of namespaces
user1385191
right, I build OOP flash apps
user1385191
except the difference is packages are used
17:42
@MattMcDonald The ".class.php" convention is an older convention I think.
PHP 5.3 added namespaces, which are like packages.
17:55
Hi phpfers
is there any API for reading emails?
POP3/IMAP etc
I don't know of any, but I'm sure there are.
@UmairAshraf protip: the php manual is an exhaustive body of knowledge: de3.php.net/manual/en/book.imap.php
I need something very easy
and quick to use
I know PHP 5 has built in functions
but that will increase work
Ha, this is awesome: erkie.github.com
@Gordon He was just asking for our help, you don't have to help him if you don't want to...
@Michael I did help him, didnt I?
18:04
Technically, yes. Practically, no.
you did
I played it
great one
@Michael what am I supposed to do? Write him the script? He asked for APIs for POP and IMAP. I gave him those.
@UmairAshraf thanks
is there a tutorial that helps me go through it?
@Umair i dont know any but most of these functions should have examples
there is also framework.zend.com/manual/en/zend.mail.read.html if you dont want to use the native extensions for POP and IMAP.
Zend Framework is a component library, so you dont have to use all of Zend Framework to use the Mail component
18:30
i have designed a php mail script using google smtp server for sending mails.
it works fine in localhost but a white page is displayed when hosted in main server.
@Karthik enable error reporting and check your error log
can anyone please help me to solve this problem????
@Gordon i have used error_reporting(E_ALL); for error reporting but of no use..
no errors are being reported only a white page is being displayed...
@Karthik check your error log
@Karthik if you dont know where the error log is located on the server do ini_get('error_log');
@Gordon u mean i have to call that method in my script. right????
yes, also make sure you set ini_set('display_errors', 1) and ini_set('display_startup_errors', 1) - otherwise you wont see any errors, even with error_reporting set to E_ALL
2
18:42
ok...thank you very much...
can you give any approximate idea what may be the cause as you might have come across with such problems???
@Karthik i have absolutely no idea what's wrong. That's why I am trying to enable error reporting with you.
@Gordon okay...no problem, i will just check the errors.
if the page still stays white after you enabled error reporting and display and there is no errors in the error log install xdebug and step through the script execution
@Gordon i have got this error wen hosted the page on my server...
Fatal error: Class 'Net_SMTP' not found in /home/vol7/byethost33.com/b33_6827453/htdocs/Mail/smtp.php on line 349
@Karthik Net_SMTP is a PEAR package: pear.php.net/package/Net_SMTP
make sure the package is available in the include path
If you dont know what your include path is do echo get_include_path()
18:55
@Gordon as mentioned in the error i am including the class in Mail folder. am i right???
@Karthik yes. Mail/smtp.php on line 349
that line probably says something like new Net_SMTP('ssl://mail.example.com', 465);
@Gordon that line consists of
$this->_smtp = &new Net_SMTP($this->host,
$this->port,
$this->localhost);
yeah. that what I said :) on a sidenote, you dont need the & before the new
now you have to make sure the Net_SMTP package is available in the include path on your server. You can install it from the command line via peardev install --force --all-deps NET_SMTP
@Gordon ok... i have downloaded the package and its extension is .0 .is it the right one???
Net_SMTP-1.6.0
did you download it from the website or did you install it via PEAR?
19:06
@Gordon i have downloaded it from the website...
then you also have to download it's dependencies
Dependencies for Net_SMTP

PEAR Installer 1.4.3
Net_Socket 1.0.7
Auth_SASL (Optional)
its really much easier to install that package with all dependencies from the command line
actually. if that script works on your development machine, then you should have all the required packages on the development machine already. so you could upload your entire pear folder to the production machine and then add the folder to the include path.
@Gordon actually whatever files and their dependencies i am having in my machine, i have uploaded everything to my server..
@Gordon can you please tell me how to install that package???
@Karthik do peardev install --force --all-deps NET_SMTP from the command line of the production server
19:22
@Gordon actually till now i was just uploading my files to server and worked with database only. Is execution of any such command allowed in the production server???
19:39
@Karthik i dont know if that is allowed on your server
if it is not allowed, go to your development server and open a command prompt and type pear config-show.
find where it says "PEAR directory". It should have a path listed for that. Upload all folders in that path to your production server.
make sure the uploaded folders are in your include_path on the production server
@Gordon command prompt of my machine says pear is not recognized as an internal or external command.
i think pear is not installed.
then either install it: pear.php.net/manual/en/installation.php or try what i wrote above
am afk now
@Gordon okay...
thank you
20:20
glah

« first day (273 days earlier)      last day (4899 days later) »