What do the dots mean in relative file path?

前端 未结 4 626
面向向阳花
面向向阳花 2020-12-17 15:44

I am new to programming and learning php on my own. I have two question about the following relative path of a file

$fp = fopen (\"$_SERVER[DOCUMENT_ROOT]/..         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-17 16:15

    .. means "go up one directory".

    So, if your DOCUMENT_ROOT was:

    /usr/docs/document_root
    

    your path works out to:

    /usr/docs/document_root/../orders/orders.txt
    

    Since the .. means "go up one", it in fact becomes:

    /usr/docs/orders/orders.txt
    

    You can see how it "erases" the "document_root" part.

提交回复
热议问题