Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Friday, August 13, 2010

W3Schools' PHP Quiz Test


I took W3Schools' online PHP Quiz Test for PHP to check if I still remember the Basics of it. And you know what, I got a Perfect score.. yippee!!! Well, the questions are too basic so if you are a PHP programmer you will surely get a perfect score too. Uhmmm.. this is not a certification test, this is just a short quiz. ^_^

If you want to try, just visit W3Schools' PHP Tutorial.


Wednesday, February 24, 2010

PHP: [Strings] Heredoc and Nowdoc


While reviewing PHP, I just discovered two new ways to handle strings.The heredoc and nowdoc.

Heredoc behaves like a double-quoted string and values inside are being parsed. You can use heredoc for embedding HTML codes.

sample:


<?php

$strString=<<< EOS
some strings
another line
EOS;

echo $strString;

?>



output:


some strings another line


the output is printed in 1 line because i didn't put a < br > in the sample codes.


Nowdoc behaves like single-quoted strings and no parsing is done inside a nowdoc.Nowdoc is good for embedding PHP code or other large blocks of text without the need for escaping.

sample:


<?php

$name="mel";
$month=2;

echo <<<'EOS'
Hi my name is $name.
My blog is $month months old.
EOS;
?>



output:


Hi my name is $name.
My blog is $month months old.



For further reading please visit http://php.net/manual/en/language.types.string.php

Friday, February 19, 2010

PHP: [Warning] session_start(): Cannot send session cookie - headers already sent by

I'm trying to review my PHP knowledge by creating a new simple web application. I know PHP is a bit different from Java but PHP is much easier to use in creating a Web application. Last night, i tried to run one of my old applications named sbp and i got this error:


[Warning] session_start(): Cannot send session cookie - headers already sent by


My SBP app is a simple registration, this was running 6 years ago. My pc OS before was Windows 2000 and i was using XAMPP, PHP version 5 and mySQL. Right now, my pc OS is Windows XP. I searched google and it said that there should be no print outputs and blank lines before calling session_start(). Is this a new rule? I also remember that my app was running perfectly in Linux ( again 6 years ago). It worked perfectly even there were "echo" statements before calling session_start(). I'm still wondering why this error occur? I know I'm too outdated. Are there any issues or new rules regarding PHP running in Windows XP?

You might also like:


Related Posts Plugin for WordPress, Blogger...