[Resolved] Conditionally requiring php scripts

Home Forums Support [Resolved] Conditionally requiring php scripts

Home Forums Support Conditionally requiring php scripts

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #672324
    Han

    Hi there,

    Is it possible to check the viewport width using PHP?

    I created a few functions in separate files and would like to ‘require’ them inside the functions.php file based on certain viewport size.

    Ed

    #672393
    David
    Staff
    Customer Support

    Hi there,

    you can’t do it simply with pure PHP, as the script is run server side. There are some methods prescribed on stackoverflow on using Ajax or redirects to pass those variables. Might be worth checking out.

    For pure PHP you can detect the UserAgent – so its device specific, heres a Stack on that:

    https://stackoverflow.com/questions/4117555/simplest-way-to-detect-a-mobile-device

    Hope it helps.

    #672457
    Han

    Hi David,

    Thanks for the information!

    I’ve decided to use http://mobiledetect.net/. Seems to be working fine.

    Ed

    #672574
    David
    Staff
    Customer Support

    Awesome 🙂 Glad to be of help.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.