PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 23rd, 2013, 06:14 AM
dazdseg dazdseg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2011
Posts: 2 dazdseg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 55 sec
Reputation Power: 0
PHP-General - Need help in using a variable in a file

Hi,

i have a config file placed in folder (/root/include/config.php)

PHP Code:
 define('SITE_BASE_PATH' '/home/techsite/public_folder/');
define('SITE_BASE_URL' 'http://' $_SERVER['HTTP_HOST'] . '/');
define('SERVER_TYPE''dev'); 


Can anyone explain me what does the above line means and how is SITE_BASE_PATH and SITE_BASE_URL = getting values. (i mean what values does these variables hold)

Another thing. i have rest of my php files (related to website ) placed in /root directory. i am using the below snippet in the code to get BASE_URL AND PATH and its not working

Code:
li class="menuitem"><a href="<?=SITE_BASE_URL;?>index.php">Home</a></li> 
<li class="menuitem"><a href="<?=SITE_BASE_URL;?>display.php">Recent Research</a></li> 
<li class="menuitem"><a href="<?=SITE_BASE_PATH;?>conferences.php">Conferences</a></li> 
<li class="menuitem"><a href="<?=SITE_BASE_PATH;?>read.php">Publication</a></li> 

the above data is present in file (index.php) placed at /root.

can someone kindly explain me why what i am doing wrong as i am new to php. please forgive if i have done any noobish mistakes.

Reply With Quote
  #2  
Old January 23rd, 2013, 06:59 AM
gw1500se gw1500se is online now
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,875 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 1 Week 6 Days 2 h 26 m 55 sec
Reputation Power: 581
Define simply defines variables based on whatever is contained in the second argument. Since they are just variables they do not output anything per se. You need to 'echo' them to get their values into the HTML.
PHP Code:
<li class="menuitem"><a href="<?echo SITE_BASE_URL;?>display.php">Recent Research</a></li
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Reply With Quote
  #3  
Old January 23rd, 2013, 07:08 AM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,851 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 12 h 36 m 16 sec
Reputation Power: 813
Hi,

those are constants, not variables. The main difference is that constants cannot be overwritten.

He also did output the constants using that weird shorthand notation: <?= ... ?>. So the problem must be something else.

@dazdseg: Are you sure you've actually included the file with the constant definitions in your index.php?
Comments on this post
gw1500se agrees: I meant constants and I messed the &lt;?=. Shame on me twice.

Reply With Quote
  #4  
Old January 24th, 2013, 12:07 AM
dazdseg dazdseg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2011
Posts: 2 dazdseg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 55 sec
Reputation Power: 0
Quote:
Originally Posted by Jacques1
Hi,

those are constants, not variables. The main difference is that constants cannot be overwritten.

He also did output the constants using that weird shorthand notation: <?= ... ?>. So the problem must be something else.

@dazdseg: Are you sure you've actually included the file with the constant definitions in your index.php?




Yes I'm pretty sure that I've included my config file in index.php .
Talking about weird notations ...Is my syntax wrong while outputting the constants ??

One thing though while I'm defining these constants :

SITE_BASE_URL..I have this variable declared $Server[HTTP_HOST] What does this mean ? How can I link my webpages with the help of this?


@gw1500se and @Jacques1 ..Thanks a ton

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-General - Need help in using a variable in a file

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap