473,480 Members | 1,850 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Building portable server addresses

The problem:

I'd like to build – with PHP – a background-image url
on a server (Apache) (url itself or a full directory name).
I'd like to use a portable mechanism, I mean a PHP script
should work in Windows, Unix and Linux. In Windows I use:

...
<style type="text/css">

..a_class
{
<?php
$S_1 = getcwd()."/images/image_1.jpg"; //BACKGROUND PICTURE
echo "background-image: url($S_1);";
?>
....

It works fine but it doesn't work in FreeBSD, for example.

Thank you in advance.

Marek Kotowski
Warsaw
Jul 17 '05 #1
4 1760
Hi Marek,

[...]
..
$S_1 = getcwd()."/images/image_1.jpg"; //BACKGROUND PICTURE It works fine but it doesn't work in FreeBSD, for example.

What version of PHP on you "TEST" System and on FreeBSD ?

Kind Regards ?
--
Dipl.Ing.(FH) Karl Heinz Marbaise | www.marbaise.org
Jabba Dabba Dooh ;-) | ICQ# 135949029

Jul 17 '05 #2
Ma************@wsip.com.pl (Marek Kotowski) wrote in message
news:<e5**************************@posting.google. com>...

I'd like to build ? with PHP ? a background-image url
on a server (Apache) (url itself or a full directory name).
I'd like to use a portable mechanism, I mean a PHP script
should work in Windows, Unix and Linux. In Windows I use:

..
<style type="text/css">

.a_class
{
<?php
$S_1 = getcwd()."/images/image_1.jpg"; //BACKGROUND PICTURE
echo "background-image: url($S_1);";
?>
...

It works fine


Only when client computer and the server are one and the same...
getcwd() returns the local name of the current working directory,
which is meaningless when client and server run on different
machines.

Here are two possible options for you:

Option One (no PHP involved, URL to the image is relative):

.a_class
{
background-image: '/images/image_1.jpg';
...
}

Option Two (some PHP involved, URL to the image is absolute):

.a_class
{
<?php
echo "background-image: 'http://",
$_SERVER['SERVER_NAME'],
"/images/image_1.jpg';";
?>
...
}

Cheers,
NC
Jul 17 '05 #3
nc@iname.com (Nikolai Chuvakhin) wrote in message news:<32**************************@posting.google. com>...
....
Here are two possible options for you:

Option One (no PHP involved, URL to the image is relative):

.a_class
{
background-image: '/images/image_1.jpg';
...
}


It doesn't work but I changed it a little to

background-image: url('images/image_1.jpg');

and this version works on Windows and FreeBSD as well.

Thank you very much.

Regards

Marek Kotowski
Warsaw
Jul 17 '05 #4
Karl Heinz Marbaise <kh********@gmx.de> wrote in message news:<c3*************@ID-68093.news.uni-berlin.de>...
What version of PHP on you "TEST" System and on FreeBSD ?


Windows XP - 4.3.2.
FreeBSD - 4.3.4.

Kind regards. :-)

Marek Kotowski
Warsaw
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
1671
by: Martin Vorbrodt | last post by:
Hi there. Is this code portable between platforms? Is it also 100% standard compliant? #include <iostream> using namespace std; class Point { public: enum COORDS { X = 0, Y, Z }; Point(int...
2
2974
by: Marc R. Bertrand | last post by:
Hello, Do some of you know some pretty good books or web tutorials on building databases, if any? By that I mean, when looking at a business, the sound way of choosing the proper fields and the...
1
1416
by: Stephen | last post by:
I've been working on some code which will hopefully allow me to transfer the contents of an arraylist on one page over to another page. The Arraylist is held in the viewstate object as it is...
4
3491
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
131
6005
by: pemo | last post by:
Is C really portable? And, apologies, but this is possibly a little OT? In c.l.c we often see 'not portable' comments, but I wonder just how portable C apps really are. I don't write...
1
2269
by: Lyners | last post by:
What I need - To retrieve the server name that the ASP application is running on. Why - Our current intranet is on a network where we have users that are on a domain and some that are not. Using...
14
2091
by: Kristan Dyson | last post by:
I was just wondering whether you knew whether it is possible to compile a fully portable C program? I want to write a 'C' CGI program on Windows, then just upload it to my Plus.Net Debian-based...
32
1992
by: r.z. | last post by:
class vector3 { public: union { float data; struct { float x, y, z; };
11
2267
by: Brian Gladman | last post by:
A lot of low level cryptographic code and some hardware cryptographic accelerators either fail completely or perform very poorly if their input, output and/or key storage areas in memory are not...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7084
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6739
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6929
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
181
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.