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
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
PHP variable parsing problem :?
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="GT9" data-source="post: 15492544" data-attributes="member: 478359"><p><span style="color: DarkRed"><span style="font-size: 15px">මචන්ලා අදත් මට වෙනද වගේම ලෙකු php කේස් එකක්...<img src="/styles/default/xenforo/smilies/default/rofl.gif" class="smilie" loading="lazy" alt=":rofl:" title="ROFL :rofl:" data-shortname=":rofl:" /><img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /><img src="/styles/default/xenforo/smilies/default/P.gif" class="smilie" loading="lazy" alt=":P" title=":P :P" data-shortname=":P" /> අද ප්රශ්නේ.. php variable value parsing problem එකක් ගැන. </span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">මෙන්න මේක තමයි අවුල... <img src="/styles/default/xenforo/smilies/default/sorry.gif" class="smilie" loading="lazy" alt=":sorry:" title="Sorry :sorry:" data-shortname=":sorry:" /> මට ඕන php variable කීපයකට dynamically values asign කරන්න.. හැබැයි මේක මට නිකන් පිස්සු වගේ.. මෙදේට හේතුව මගේ script එක ලියපු විදියට.. ඒ මුලු script එකම වෙනස් කරන්නත් බෑ.. <img src="/styles/default/xenforo/smilies/default/eek.gif" class="smilie" loading="lazy" alt=":eek:" title="eek :eek:" data-shortname=":eek:" /><img src="/styles/default/xenforo/smilies/default/baffled.gif" class="smilie" loading="lazy" alt=":baffled:" title="Baffled :baffled:" data-shortname=":baffled:" /></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">මට ඕන මෙන්න මේකයි මචන්ලා...</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">මෙන්න මේ ආකාරයේ.. function එකක් තියෙනවා..</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">function print($firstName, $lastName){</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">echo $firstName.$lastName;</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">} </span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">දැන් අපිට පුලුවන්නේ.. මේවිදියට ඉහත function එකේ parameters වලට values asign කරන්න...</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">print('Malaka','Silva');</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">දැන් ඉතින් ඔය ඉහත විදියට parameters දීල function එක call කරාම අවුලක් නැතිව වැඩේ වෙනවනේ.. එතනට එනකම් මට ගැටලුවක් නෑ... නමුත් මගේ script එකේ structure එකේ තියෙන මඥ්ඥං බව නිසා.. මට මේවගේ පිස්සු වැඩක් කරන්න ඕන වෙලා තියෙනවා...</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">මගේ තියෙනවා.. Index.php file එකක්..ඒක මේවගේ..</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"><?php</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">require 'basic_functions.php'; // this file has print function</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">// print title position</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">// print header position</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">print('Malaka','Silva');</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">if (empty($_GET['page'])) {</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">echo "defualt root index page ";</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">} else{</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> $page = $_GET['page']; </span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> switch ($page)</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> {</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> case "red":</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> echo "Your favorite color is red!";</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> print('Janaka','Saliya');</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> break;</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> case "blue":</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> echo "Your favorite color is blue!";</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> print('Ranuka','Silva');</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> break;</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> case "green":</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> echo "Your favorite color is green!";</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> break;</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> default:</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> echo "Your favorite color is neither red, blue, or green!";</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"> } // end switch selection block</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">}</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">// other elements calling</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">// other elements calling</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">?></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">ඔය ඉහත් index php file එකට මචන් require මගින්.. print function එක තියෙන basic_functons.php කියන file එක call කරල තියෙන්නේ... ඔය ඉහත.. index file එකේ.. </span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">// print header position එකට යටින් තියෙනවනේ.. මේ වගේ statement එකක්...print('Malaka','Silva'); මෙන්න මෙතන තමයි මචන්.. මට හැම පේජ් එකේදිම මේ function එක වැඩ කරන්න ඕනේ.. </span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">නමුත් බලන්න. මම ඔය switch selection block එකේත්.. ඔය විදියට print() function එක විවිද parameters දාල කෝල් කරා තියෙනවා.. එතකොට.. ඒඒ page index එකේදී..</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">උදා-</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">example.com/?page=red</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">example.com/?page=blue</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">අර print(); function එක වැඩ කරනවා.. නමුත් මට ඕන ඒ ඒ තැන් වල <span style="color: Red">වැඩ නොකර</span>.. අර ඉහත // print header position මෙන්න මේ තැනට පහලින් තියෙන තැන වැඩකරන්න..</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">මට ඕන.. ඒ ඒ switch statement එකේදී විවිද parameters මේ print() එකට දෙන්න.. හැබැයි ඒවා ඒ තැන්වලම වැඩ නොකර අර ඉහත තැනදී විතරක් වැඩ කරන්න තමයි.. ඕන... </span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">මම දන්නවා.. function එකක් call කරාම ඒ ස්තානයේ තමයි වැඩ කරන්නේ කියලා...<img src="/styles/default/xenforo/smilies/default/baffled.gif" class="smilie" loading="lazy" alt=":baffled:" title="Baffled :baffled:" data-shortname=":baffled:" /> මට ඕන. මේවිදියට නැතත් වෙන විදියකට වරි මේ දේ කරගන්න..</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">මචන් මේ ප්රශ්නෙදි නම් මම මාර විදියට වැටිල ඉන්නේ... මේකට උදව්වක් කරන්.. මට පුලුවන් විදියට මම ප්රශ්ණය පැහැදිලි කරා.. ඔයාලට තේරුනා කියලා හිතනවා...<img src="/styles/default/xenforo/smilies/default/yes.gif" class="smilie" loading="lazy" alt=":yes:" title="Yes :yes:" data-shortname=":yes:" /><img src="/styles/default/xenforo/smilies/default/P.gif" class="smilie" loading="lazy" alt=":P" title=":P :P" data-shortname=":P" /><img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">ඔයාල මේක localhost එකේ test කරන්න.. මම සරල උදාහරණයක් හැදුව.. මේක download කරගෙන මට මේදේකරන හැටි කියල දෙන්න... <img src="/styles/default/xenforo/smilies/default/P.gif" class="smilie" loading="lazy" alt=":P" title=":P :P" data-shortname=":P" /></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px">------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"></span></span></p><p><span style="color: DarkRed"><span style="font-size: 15px"><strong><span style="font-size: 18px"><span style="color: Red"><p style="text-align: center">Update!!! Sample script attached <img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /></p></span></span></strong></span></span></p><p style="text-align: center"><span style="color: DarkRed"><span style="font-size: 15px"><strong><span style="font-size: 18px"><span style="color: Red"></span></span></strong></span></span></p><p style="text-align: center"><span style="color: DarkRed"><span style="font-size: 15px"><strong><span style="font-size: 18px"><span style="color: Red"><span style="font-family: 'Arial Black'"><span style="font-size: 22px">[ATTACH]47232[/ATTACH]</span></span></p></p> <p style="text-align: center"></p></span></span></strong></span></span></p><p style="text-align: center"><span style="color: DarkRed"><span style="font-size: 15px"><strong><span style="font-size: 18px"><span style="color: Red">ඔය සරල උදාහරණයේ.. මචන් එක එක page index එකේදී.. එක එක <title></title> හැදේවී.. නමුත්.. ඒවා හැදෙන්නේ... <Body></body> එක ඇතුලේ.. මට ඕනේ.. ඒව <Head></head> එක ඇතුලේ හැදෙන්.. හැම පේජ් එකේම එකම තැනදී.. ඒකියන්නේ...<head></head> ටැග් ඇතුලේ යම් නිෂ්චිත ස්ථානයක.. මේක බලාගන්න.. page source code එක බලන්න.. </p></span></span></strong></span></span></p><p style="text-align: center"><span style="color: DarkRed"><span style="font-size: 15px"><strong><span style="font-size: 18px"><span style="color: Red"></p></span></span></strong></span></span></p><p style="text-align: center"><span style="color: DarkRed"><span style="font-size: 15px"><strong><span style="font-size: 18px"><span style="color: Red">මම දන්නවා.. function එකක call කරන තැන තැන තමයි.. ආදාල කෝඩ් එක generate වෙන්නේ... ඒක තමයි මේ අවුල... වෙනවිදියට හරි කමක් නෑ මේ දේකරන විදියට මට කියලා දෙන්න ලොකු උදව්වක්....</p></span></span></strong></span></span></p><p style="text-align: center"><span style="color: DarkRed"><span style="font-size: 15px"><strong><span style="font-size: 18px"><span style="color: Red"></p></span></span></strong></span></span></p><p style="text-align: center"><span style="color: DarkRed"><span style="font-size: 15px"><strong><span style="font-size: 18px"><span style="color: Red"></p><p></span></span><span style="color: Red"><p style="text-align: center"></p><p></span><p style="text-align: center"></p><p></strong></span></span></p></blockquote><p></p>
[QUOTE="GT9, post: 15492544, member: 478359"] [COLOR="DarkRed"][SIZE="4"]මචන්ලා අදත් මට වෙනද වගේම ලෙකු php කේස් එකක්...:rofl::D:P අද ප්රශ්නේ.. php variable value parsing problem එකක් ගැන. මෙන්න මේක තමයි අවුල... :sorry: මට ඕන php variable කීපයකට dynamically values asign කරන්න.. හැබැයි මේක මට නිකන් පිස්සු වගේ.. මෙදේට හේතුව මගේ script එක ලියපු විදියට.. ඒ මුලු script එකම වෙනස් කරන්නත් බෑ.. :eek::baffled: මට ඕන මෙන්න මේකයි මචන්ලා... මෙන්න මේ ආකාරයේ.. function එකක් තියෙනවා.. function print($firstName, $lastName){ echo $firstName.$lastName; } දැන් අපිට පුලුවන්නේ.. මේවිදියට ඉහත function එකේ parameters වලට values asign කරන්න... print('Malaka','Silva'); දැන් ඉතින් ඔය ඉහත විදියට parameters දීල function එක call කරාම අවුලක් නැතිව වැඩේ වෙනවනේ.. එතනට එනකම් මට ගැටලුවක් නෑ... නමුත් මගේ script එකේ structure එකේ තියෙන මඥ්ඥං බව නිසා.. මට මේවගේ පිස්සු වැඩක් කරන්න ඕන වෙලා තියෙනවා... මගේ තියෙනවා.. Index.php file එකක්..ඒක මේවගේ.. <?php require 'basic_functions.php'; // this file has print function // print title position // print header position print('Malaka','Silva'); if (empty($_GET['page'])) { echo "defualt root index page "; } else{ $page = $_GET['page']; switch ($page) { case "red": echo "Your favorite color is red!"; print('Janaka','Saliya'); break; case "blue": echo "Your favorite color is blue!"; print('Ranuka','Silva'); break; case "green": echo "Your favorite color is green!"; break; default: echo "Your favorite color is neither red, blue, or green!"; } // end switch selection block } // other elements calling // other elements calling ?> ඔය ඉහත් index php file එකට මචන් require මගින්.. print function එක තියෙන basic_functons.php කියන file එක call කරල තියෙන්නේ... ඔය ඉහත.. index file එකේ.. // print header position එකට යටින් තියෙනවනේ.. මේ වගේ statement එකක්...print('Malaka','Silva'); මෙන්න මෙතන තමයි මචන්.. මට හැම පේජ් එකේදිම මේ function එක වැඩ කරන්න ඕනේ.. නමුත් බලන්න. මම ඔය switch selection block එකේත්.. ඔය විදියට print() function එක විවිද parameters දාල කෝල් කරා තියෙනවා.. එතකොට.. ඒඒ page index එකේදී.. උදා- example.com/?page=red example.com/?page=blue අර print(); function එක වැඩ කරනවා.. නමුත් මට ඕන ඒ ඒ තැන් වල [COLOR="Red"]වැඩ නොකර[/COLOR].. අර ඉහත // print header position මෙන්න මේ තැනට පහලින් තියෙන තැන වැඩකරන්න.. මට ඕන.. ඒ ඒ switch statement එකේදී විවිද parameters මේ print() එකට දෙන්න.. හැබැයි ඒවා ඒ තැන්වලම වැඩ නොකර අර ඉහත තැනදී විතරක් වැඩ කරන්න තමයි.. ඕන... මම දන්නවා.. function එකක් call කරාම ඒ ස්තානයේ තමයි වැඩ කරන්නේ කියලා...:baffled: මට ඕන. මේවිදියට නැතත් වෙන විදියකට වරි මේ දේ කරගන්න.. මචන් මේ ප්රශ්නෙදි නම් මම මාර විදියට වැටිල ඉන්නේ... මේකට උදව්වක් කරන්.. මට පුලුවන් විදියට මම ප්රශ්ණය පැහැදිලි කරා.. ඔයාලට තේරුනා කියලා හිතනවා...:yes::P:D ඔයාල මේක localhost එකේ test කරන්න.. මම සරල උදාහරණයක් හැදුව.. මේක download කරගෙන මට මේදේකරන හැටි කියල දෙන්න... :P ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [B][SIZE="5"][COLOR="Red"][CENTER]Update!!! Sample script attached :D [CENTER][FONT="Arial Black"][SIZE="6"][ATTACH]47232._xfImport[/ATTACH][/SIZE][/FONT][/CENTER] ඔය සරල උදාහරණයේ.. මචන් එක එක page index එකේදී.. එක එක <title></title> හැදේවී.. නමුත්.. ඒවා හැදෙන්නේ... <Body></body> එක ඇතුලේ.. මට ඕනේ.. ඒව <Head></head> එක ඇතුලේ හැදෙන්.. හැම පේජ් එකේම එකම තැනදී.. ඒකියන්නේ...<head></head> ටැග් ඇතුලේ යම් නිෂ්චිත ස්ථානයක.. මේක බලාගන්න.. page source code එක බලන්න.. මම දන්නවා.. function එකක call කරන තැන තැන තමයි.. ආදාල කෝඩ් එක generate වෙන්නේ... ඒක තමයි මේ අවුල... වෙනවිදියට හරි කමක් නෑ මේ දේකරන විදියට මට කියලා දෙන්න ලොකු උදව්වක්.... [/CENTER][/COLOR][/SIZE][COLOR="Red"][CENTER][/center][/COLOR][CENTER][/CENTER][/B][/SIZE][/COLOR][SIZE="4"][B][/b][/SIZE][B][/B] [/QUOTE]
Insert quotes…
Verification
Nawa warak dahaya keeyada? (Namaya wadi kireema dahaya)
Post reply
Top
Bottom