| | |
Current Working directory
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hi All,
I'm using XAMMP server in USB stick and have Web project in this structure:
F:\xampplite\htdocs\projects\Elijah
So my current working DIR is elijah. However, I don't want to write the long path "../projects/elijah/elijah.css" when linking css file or using images. I would like to use something like a function that will retrieve current working directory so that path will be
"The_function_to_get_DIR/elijah.css" I want the root to be seen virtually as elijah
Thanks for your help, and I'm ready to clarify wherever there's ambiguity
I'm using XAMMP server in USB stick and have Web project in this structure:
F:\xampplite\htdocs\projects\Elijah
So my current working DIR is elijah. However, I don't want to write the long path "../projects/elijah/elijah.css" when linking css file or using images. I would like to use something like a function that will retrieve current working directory so that path will be
"The_function_to_get_DIR/elijah.css" I want the root to be seen virtually as elijah
Thanks for your help, and I'm ready to clarify wherever there's ambiguity
php Syntax (Toggle Plain Text)
include("./thisfile");
html Syntax (Toggle Plain Text)
<link rel="stylesheet" type="text/css" media="screen" href="./style.css">
php Syntax (Toggle Plain Text)
$basedir=substr("$_SERVER['SCRIPT_FILENAME']",0,strripos("$_SERVER['SCRIPT_FILENAME'],"/",0));
Last edited by almostbob; Feb 21st, 2009 at 3:50 pm.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
First two, . is the default for current folder, as .. is parent
third one
take the current script name as known to the server and break it at the last / character
substring of the server array, from position 0 to the position of the last /
this gives the documentroot path to the current folder
third one
take the current script name as known to the server and break it at the last / character
substring of the server array, from position 0 to the position of the last /
this gives the documentroot path to the current folder
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
Ok I have this code:
How do I link the CSS file using PHP in that, Instead of full CSS path I will have href="$paths/elijah.css" ?
Thanks for your valuable reply
How do I link the CSS file using PHP in that, Instead of full CSS path I will have href="$paths/elijah.css" ?
Thanks for your valuable reply
php Syntax (Toggle Plain Text)
html> <head> <title>Test Page - Elijah Ministries</title> <?php $paths = getcwd(); print $paths; ?> <link rel = "sheet" style = "text/css" href = "/project/elijah/elijah.css" /> </head> <body> <table width="100%" height="450px" bgcolor="silver"> <tr> <td class="top_header"> </td> </tr> </table> </body> <html>
May be question was too vague, here is another way,
I get path of current DIR via php script
Then I want to use this path when linking all my image and css file
Here is my code linking the CSS file
How do I link the CSS file using $paths that is <link rel = "sheet" style = "text/css" href = "$paths/elijah.css" />
Thanks for your invaluable help
I get path of current DIR via php script
php Syntax (Toggle Plain Text)
<?php $paths = getcwd(); ?>
Then I want to use this path when linking all my image and css file
Here is my code linking the CSS file
php Syntax (Toggle Plain Text)
<link rel = "sheet" style = "text/css" href = "/project/elijah/elijah.css" />
How do I link the CSS file using $paths that is <link rel = "sheet" style = "text/css" href = "$paths/elijah.css" />
Thanks for your invaluable help
Last edited by peter_budo; Feb 25th, 2009 at 8:04 pm. Reason: Closing tag is [/code] not [/php]
Your code
shouild be
even before you make it
html Syntax (Toggle Plain Text)
<link rel = "sheet" style = "text/css" href = "/project/elijah/elijah.css" />
html Syntax (Toggle Plain Text)
<link rel="stylesheet" type="text/css" href="/project/elijah/elijah.css" />
html Syntax (Toggle Plain Text)
<link rel="stylesheet" type="text/css" href="./elijah.css" />
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
Yeah, that error is obvious, but I failed to see it. Thanks.
It is that I'm refactoring my old HTML code to incorporate PHP. However, My working folder in XAMPP ("/project/elijah/elijah.css") will not be valid when kept on server where path will be something like "/elijah.css". So I want to use path to avoid changing things in file, which is tedious work
It is that I'm refactoring my old HTML code to incorporate PHP. However, My working folder in XAMPP ("/project/elijah/elijah.css") will not be valid when kept on server where path will be something like "/elijah.css". So I want to use path to avoid changing things in file, which is tedious work
![]() |
Similar Threads
- How to get the current working directory (C++)
- File doesn't upload into the directory I specified. Need help! (PHP)
- Setting directory for opening files (Python)
- Directory and folder (C++)
- find a specific directory (Java)
Other Threads in the PHP Forum
- Previous Thread: Help Me! A PHP Network Project
- Next Thread: Dynamic Forms with PHP/mySQL
Views: 873 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date datepart directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link list login loop mail menu methods mlm mod_rewrite multiple mysql oop parse password paypal pdf php problem query radio random recursion regex remote script search select seo server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web webdesign xml youtube






