English 中文(简体)
为什么把 Java的路子连接起来并不需要预选,而项目组合中的道路却包括进去?
原标题:Why do link paths in JavaScript not require a precedding / but paths in PHP includes do?

声响灯,但我需要一小时左右。

我的一条道路是 Java本。

const JAVASCRIPT =               host/source/ArcJB.js ;

在我文件中提出:

<script type="text/javascript" src="host/source/ArcJ.js"></script>

如果我在前面的<代码>/中填满了这一链接。

在PHP中,用于服务器边的道路一:

<?php
    include_once getcwd() . "/host/source/class.ControlEntry.php";

如果我没有在<条码>/上填满,便会打断。

我在概念上猜测,我是否敢于知道这一点,因此,我不必用审判和错误把我的头发拉开?

还注意到:

我的杰斯内部的航道,在这条路之前,有一条<条码>/,或没有一条<条码>。

这些用于图像勘测或麻风病。

最佳回答

预想的斜坡被用来表示道路应被视为一条绝对的道路,这意味着,

  1. For your Js path, which resides in a HTML file which is parsed by a browser to render its content, it should append what you wrote to the domain to get the file. And if your Js file is located relatively to the current page your snippet is located, the link may break.
  2. For your php file, it is located in a path which can be accessed by following system root to host/source/class.ControlEntry.php
问题回答

你们应当知道,你通过<代码>include_once的道路在服务器上解决,而 Java脚路由浏览器解决。 两者基本遵循相同的规则:

  • paths starting with / are resolved absolutely. On the server, this is the root directory (i.e. the topmost directory). In the browser, this is basically concatenating the host and the path that you are specifying.
  • paths not starting with a / are relatively resolved, i.e. against the current directory on the server and against the path in your browser.

Realize that getcwd() returns a directory like /var/www. If you then just concanate host/source/class.ControlEntry.php to it, it will yield /var/wwwhost/source/class.ControlEntry.php. On most (if not, all) PHP SAPI s, you can leave out the getcwd() thing when including a file as the current directory is already being searched when including files. In this case, you do not need the / either.

最后,服务器文档途径不必与URLs相匹配! http://example.com/script.php 可查阅/var/www/script.js。 如果你在超文本档案中提及/script.php,将予以正确解决。 另一方面,你不应尝试<代码>include "/script.php>,在你档案系统根基中搜索一个文件script.php,而这个系统往往不是你所期望的。

你们知道,哪里有档案。 对他们使用相对或绝对的道路,并将在PHP和Java文本中工作。

在你的例子中,前面的<代码>/将使路向其他地方指明,从而打破应用。 在您的PHP中,你特别想到铺路,这将取决于对<代码>getcwd(的评价。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签