Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Puffin Rock Characters Plush Toy Set
anil1961
Updated:
Nov 7, 2026
Toyota Vitz scp10 For Sale
Lakmal Bandara
Updated:
Nov 4, 2026
Kandy
Welcome all my all new pet shop Bark.lk
dilumrane
Updated:
Nov 2, 2026
Windows RDP Only Rs.500 a month
Blogerwiki
Updated:
Nov 1, 2026
Ad icon
V2ray VPN for Tunneling
hu KANNA
Updated:
Oct 22, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
Another PHP problem machan :(
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Ayeshlive" data-source="post: 15390424" data-attributes="member: 363439"><p>මචන් ඔය ඔතන function එක ඇතුලේ echo කරනවා. ඒ නිසා PHP කරන්නේ ඉස්සරලා name එක print කරන එක. echo එකේ return එකක් නෑ. </p><p></p><p>අනිත් එක global keyword එක use කරන්න කලින් ඒක global scope ekema define කරලා තියෙන්න ඕනේ me widihata:</p><p><a href="http://3v4l.org/9EsTb" target="_blank">http://3v4l.org/9EsTb</a></p><p>[PHP]<?php</p><p>function set_name($name) {</p><p> $GLOBALS['name'] = $name;</p><p>}</p><p></p><p>function get_name() {</p><p> return $GLOBALS['name'];</p><p> /* Above line is equal to:</p><p> * global $name;</p><p> * return $name;</p><p> */</p><p>}</p><p></p><p>function wrap($txt) {</p><p> echo 'Your username is ' . get_name() . ' ' . $txt;</p><p>}</p><p></p><p>/* You should not print/echo stuff in a function. So the better way would be:</p><p> * function wrap($txt) {</p><p> * return 'Your username is ' . get_name() . $txt;</p><p> * }</p><p> * echo wrap($txt)</p><p> */</p><p></p><p> </p><p>// Usage:</p><p></p><p>set_name('Rajitha');</p><p>wrap('tobacco');</p><p>?>[/PHP]</p></blockquote><p></p>
[QUOTE="Ayeshlive, post: 15390424, member: 363439"] මචන් ඔය ඔතන function එක ඇතුලේ echo කරනවා. ඒ නිසා PHP කරන්නේ ඉස්සරලා name එක print කරන එක. echo එකේ return එකක් නෑ. අනිත් එක global keyword එක use කරන්න කලින් ඒක global scope ekema define කරලා තියෙන්න ඕනේ me widihata: [URL]http://3v4l.org/9EsTb[/URL] [PHP]<?php function set_name($name) { $GLOBALS['name'] = $name; } function get_name() { return $GLOBALS['name']; /* Above line is equal to: * global $name; * return $name; */ } function wrap($txt) { echo 'Your username is ' . get_name() . ' ' . $txt; } /* You should not print/echo stuff in a function. So the better way would be: * function wrap($txt) { * return 'Your username is ' . get_name() . $txt; * } * echo wrap($txt) */ // Usage: set_name('Rajitha'); wrap('tobacco'); ?>[/PHP] [/QUOTE]
Insert quotes…
Verification
Dahaya deken beduwama keeyada?
Post reply
Top
Bottom