smartguyin Posted March 2, 2006 Share Posted March 2, 2006 I have set a variable as below$title = "My Product Title"I have created this variable in index.php and i wanted to use it in product.php how can i transfer from index.php to product.php soo that i can directly use it in all the product pages... like in title tag <title>[title]</title>Please give me your suggestions.Thanks in Advance Quote Link to comment Share on other sites More sharing options...
budeboy Posted March 2, 2006 Share Posted March 2, 2006 You could do it using sessions but if the variable is set in index.php they would have to have been on index.php for it to work on the other pages.I think the best way would be to set it in an external file then calling that file on the pages you want the variable to be used on.e.g. the code in the file would be[code]$title = "This is the title";[/code]and the code you would use to call it would be (assuming the file was called title.inc)[code]include("title.inc");[/code]hope that helps Quote Link to comment Share on other sites More sharing options...
smartguyin Posted March 3, 2006 Author Share Posted March 3, 2006 No in the above example you showed me to prepare a separate file title.inc NO i don't want to use this.[b]I want the index.php send the variable directly to product.php soo that the variable content in index.php and used in product.php directly.[/b] Quote Link to comment Share on other sites More sharing options...
smartguyin Posted March 4, 2006 Author Share Posted March 4, 2006 Please Help ! I know many people have used such thing please guys i need your help ! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 4, 2006 Share Posted March 4, 2006 How are your users getting from index.php to product.php?A form? A link?You can always uses sessions. In index.php[code]<?phpsession_start();$some_variable = "Testing 123";$_SESSION['some_variable'] = $some_variable;?>[/code]In product.php:[code]<?phpsession_start();$some_varible=$_SESSION['some_variable'];?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
smartguyin Posted March 4, 2006 Author Share Posted March 4, 2006 I'll give another example too get it more simplify.Suppose there are 2 files product.php and header.phpheader.php contains the meta tag and heading html code which is most common in all the product pages.product.php contains the other part with all the content. >> There is a heading used in this page using this $product Now I want to use the $product info in my header.php in title tag soo that the heading can be displayed in title tag.I Hope the things must be clear now..Thanks in Advance ! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 4, 2006 Share Posted March 4, 2006 No, it's still clear as mud. Do you have any code you can post? Indicate what you want where...Ken Quote Link to comment Share on other sites More sharing options...
dayo Posted October 12, 2006 Share Posted October 12, 2006 [quote author=kenrbnsn link=topic=87296.msg351524#msg351524 date=1141445981]How are your users getting from index.php to product.php?A form? A link?You can always uses sessions. In index.php[code]<?phpsession_start();$some_variable = "Testing 123";$_SESSION['some_variable'] = $some_variable;?>[/code]In product.php:[code]<?phpsession_start();$some_varible=$_SESSION['some_variable'];?>[/code]Ken[/quote]New here but desperately going through old files. I probably should post here as i had put this somewhere else but this is relevant to my quest so I hope I am forgiven.I am tying to modify some files that have the following simplified structure[code]<?phpinclude 'a.inc';include 'b.inc';?>a.inc has the following struture<?php"A form for user input"include 'A1.inc';include 'A2.inc';?>A1.inc has the following struture<?phpfunction 1 {$x = "Value from user input form"}?>A2.inc has the following struture<?phpfunction 2 {$y = $x + 1}include 'A2_1.inc';?>A2_1.inc has the following struture<table><tr><td>"The value of $y"</td></tr></table>[/code]The files are a bit more complicated than this (Gallery2 photo display software) but this is the basic structure. I am struggling to get "The value of $y". Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.