-2

For some reason I have developed two sites for mobile and desktop.

So all the things are different such as php, js, css. But I should use same db and image.

I need code like this.

if(mobile) {
    include 'mobile/aa.php';
} else {
   include 'desktop/aa.php';
}

same thing will be applied in js and css.

In this case how can I realize it. Please help me.

I found lots of methods such as redirect url, css and js using screen size.

But this way is not good for me.

Please let me know is it possible or not.

Darren
  • 13,050
  • 4
  • 41
  • 79
wuang li
  • 71
  • 1
  • 8
  • 2
    why don't you just bootstrap it? Go responsive man; it's the *in thing!* – Funk Forty Niner Aug 04 '16 at 01:06
  • 1
    Either do what @Fred-ii- said above or "hack" your way through redirects. PHP doesn't know (*reliably*) what type of device is accessing it (Especially when you can spoof your user agent), as view widths/etc are more accessible by bootstrapping it. – Darren Aug 04 '16 at 01:10
  • 1
    [*Yeah baby!...*](https://www.youtube.com/watch?v=J2HBdRCroks) @Darren – Funk Forty Niner Aug 04 '16 at 01:12
  • Thanks. but I need. Actually my site is betting site, and I need only one page. Because lots of data should be used. Thanks. – wuang li Aug 04 '16 at 01:48

2 Answers2

1

Basically it is not good idea to developed two different sites.you can use responsive web design and .htaccess to block features if not needed on mobile device you can do something like below which was found here

  if(navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|IEMobile)/)){ 
  var js = document.createElement('script');
  js.type = "text/javascript";
  js.src = "/s/jquery.dropkick-1.0.0.js";

  var css = document.createElement('link');
  css.type = "text/css";
  css.rel = "stylesheet";
  css.href = "/c/dropkick.css";

  var h = document.getElementsByTagName('head')[0];
  h.appendChild(js);
  h.appendChild(css);

}

Community
  • 1
  • 1
PalakM
  • 301
  • 2
  • 17
  • Thanks. I think you are right. but I know this method. But if my site is in the mobile it will not work because the battery of site will be off. That is why I should make the code for mobile and desktop. Please send me another good idea. – wuang li Aug 04 '16 at 01:52
0

Basically PHP won't be able to know if client-side is a mobile or desktop only when you pass the parameter to tell the PHP so.

Simply use the responsive in CSS would solve your case.

noob
  • 480
  • 3
  • 20
  • Thanks. already I knew it. But I need another way. My site is special site. so I cannot use this. – wuang li Aug 04 '16 at 01:56
  • You can specify more details. I am not sure about "But if my site is in the mobile it will not work because the battery of site will be off." Without more details I can't figure out what do you really need. – noob Aug 04 '16 at 02:09
  • Thanks for your kindly help. OK. I will send more details. please see the site m.wifoot.ht (for mobile) demo.wifoot.ht.(for desktop). – wuang li Aug 04 '16 at 13:32
  • I still can't see any thing like battery on your mobile demo site. – noob Aug 04 '16 at 22:45