Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9142019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:43:19+00:00 2026-06-17T09:43:19+00:00

echo dirname(‘/test’); That outputs \ for me. I’d expect it to output /. echo

  • 0
echo dirname('/test');

That outputs \ for me. I’d expect it to output /.

echo dirname('/test/a');

That outputs /test for me so why isn’t /test giving me / as well?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:43:20+00:00Added an answer on June 17, 2026 at 9:43 am

    Check this from http://php.net/manual/en/function.dirname.php

    <?php
    echo "1) " . dirname("/etc/passwd") . PHP_EOL; // 1) /etc
    echo "2) " . dirname("/etc/") . PHP_EOL; // 2) / (or \ on Windows)
    echo "3) " . dirname("."); // 3) .
    ?>
    

    Since windows uses both / and \ as directory separator, this happens.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

echo date(W,strtotime('2010-01-01')); This outputs 53. I would expect it to output 1. Can anyone
How to remove the last dir with sed (not dirname ), like this: echo
echo '<img src=../../images/delete.png id=aaa />aaa&nbsp;&nbsp;&nbsp;'; (working fine) //define( 'ROOT_DIR', dirname(__FILE__) ); is in a
Say I have a symlink from '/one/directory/' to '/two/directory/' . If I echo dirname(dirname(\__FILE__))
with echo realpath('.').'<br>'; echo dirname(__FILE__).'<br>'; echo realpath(dirname(__FILE__)).'<br>'; echo $_SERVER[PHP_SELF].'<br>'; echo getcwd(); I get always
I am using this: echo dirname(__FILE__); which gives: C:\UwAmp\www\myfolder\admin However I am looking for
Say, I have a shell script like this: utils.sh function getDir { echo "DirName"
echo date('H:i', time()); // 10:15 echo date('H:i', strtotime($this->deadline)); // 10:05 $delay = time() -
echo timezone_name_from_abbr(, 3600*7, 0); //ok echo timezone_name_from_abbr(, 3600*8, 0); //NOT ok! return nothing! echo
echo date(w,strtotime(date(Y-m-d))); echo date(w,strtotime(date(Y年m月d日))); Save it as utf8.You'll see the second is bigger than

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.