# How to know if files is executing on local or sever

**URL:** <https://forum.kirupa.com/t/how-to-know-if-files-is-executing-on-local-or-sever/261922>\
**Category:** Uncategorized\
**Created:** [June 1, 2008, 9:12pm UTC](https://forum.kirupa.com/t/how-to-know-if-files-is-executing-on-local-or-sever/261922 "2008-06-01T21:12:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pier25](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pier25](https://forum.kirupa.com/u/Pier25)\
**Post date:** [June 1, 2008, 9:12pm UTC](https://forum.kirupa.com/t/how-to-know-if-files-is-executing-on-local-or-sever/261922/1 "2008-06-01T21:12:49Z")

</div>

On most of my projects I end up having a dynamic xml for online testing, and an .xml file when I work locally.

What I do is having all the config vars on the top of my code, and comment depending wether I’m working locally or on the server.

as en example

//server  
xml\_file = “[http://mydomain.com/mywebservice.php](http://mydomain.com/mywebservice.php)”

//local  
xml\_file = “myfile.xml”

What would be really handy for me, instead of commenting each block each time, would be having a conditional:

if(we’re online){  
xml\_file = “[http://mydomain.com/mywebservice.php](http://mydomain.com/mywebservice.php)”  
} else {  
xml\_file = “myfile.xml”  
}

… but I don’t know how I can approach that.

Any ideas?

TIA

---

<div class="post-metadata">

**Author:** ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)\
**Post date:** [June 1, 2008, 9:37pm UTC](https://forum.kirupa.com/t/how-to-know-if-files-is-executing-on-local-or-sever/261922/2 "2008-06-01T21:37:20Z")

</div>

I like to set a create a global file for the project called something like _local\_settings.php_ that isn’t tracked by the SCM, which includes constants such as _DEBUG_ and _LIVE_. When this file is included elsewhere, you can easily evaluate these in conditionals to act based on the local settings.

---

<div class="post-metadata">

**Author:** ![dail](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@dail](https://forum.kirupa.com/u/dail)\
**Post date:** [June 1, 2008, 10:41pm UTC](https://forum.kirupa.com/t/how-to-know-if-files-is-executing-on-local-or-sever/261922/3 "2008-06-01T22:41:18Z")

</div>

Try this;

```auto

var path:String = this.loaderInfo.url
			if(path.search("http") == -1){
				//you are not online
				
			}

```
