Skip to content

PHP extended paths (PATH_INFO)

March 1, 2013

I was using a file which included a style sheet. It did not include a path (relative path).

<link href="style.css" rel="stylesheet" type="text/css">

However, when I added an extended path (information like file.php/extra) the href no longer worked. I used the following snippet to insert the real path name before the file so that it resolves, even with extended path information.

<?php
  $thisscript = $_SERVER["SCRIPT_NAME"];
  $thispath = pathinfo($thisscript, PATHINFO_DIRNAME);
?>
<link href="<?php echo $thispath."/" ?>style.css" rel="stylesheet" type="text/css">
Advertisements

From → Technology

One Comment
  1. phpabhishek permalink

    Reblogged this on PHPAbhishek.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: