I need something like this
user enters a website link
I need to check the link if the link does not start with 'http: //' I want to add the link "http: //" to the link.
how can i do this in php?
if (stripos($url, 'http://') !== 0) { $url = 'http://' . $url; }
I recommend a slight improvement over tom
if (0 !== stripos($url, 'http://') && 0 !== stripos($url, 'https://')) { $url = 'http://' . $url; }
However, this will ruin the links that use other protocols (ftp: // svn: // gopher: // etc.)
if (!preg_match("/^http:\/{2}/",$url)){ $url = 'http://' . $url; }
, . URI "" (http, ftp ..) " ". , - () mailto , .
Source: https://habr.com/ru/post/1699281/More articles:Mach-O for OSX? - editorBuildfarms: Options - compiler-constructionПочему я не могу использовать статические элементы, например статические структуры, в моих классах в VS2008? - c++Can I make iPhone apps using only OpenGL and not Cocoa Touch? - cHow can I safely link to ASP classic files that contain files outside the root directory? - securityHow to read "company name" from Windows using C #? - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1699283/net-forms-authentication-how-to-limit-access-to-resources-like-pdf-files-to-authenticated-users-only&usg=ALkJrhgM8247G8D-82LpiAXds2uhhccymQДублировать список SharePoint - sharepointHow to rewrite Adobe Photoshop plugins for Adobe Lightroom? - pluginsNullReference exception when placing WPF in System.AddIn - .netAll Articles