Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this string echo 0?

Tags:

string

php

echo

When I try and echo this string it shows "0"

I tried it on my local server and on http://writecodeonline.com/php/ both times same thing happened. This has never happened to me before, what is it and how do I fix? Thanks in advance.

<?PHP
$info = '
                <div id="gallery_option_###number###">
                    <a href="#galleryButton###number###" onclick="gallery_button_down(' + "'###number###'" + ')">
                        Burn Notice
                    </a>
                    <div id="info_option_###number###">
                        <!--
                        [title]title[|title]
                        [description]test[|description]
                        [image]url[|image]
                        -->
                    </div>
                </div>';
                echo $info;
?>
like image 201
Patrick Lorio Avatar asked Sep 04 '11 03:09

Patrick Lorio


1 Answers

You are following JavaScript way of string concatenation.

Read:

http://php.net/manual/en/language.operators.string.php

<?php
$a = "Hello ";
$b = $a . "World!"; // now $b contains "Hello World!"

$a = "Hello ";
$a .= "World!";     // now $a contains "Hello World!"
?>
like image 140
Naveed Avatar answered Nov 04 '22 23:11

Naveed