PHP 8x Use Of Str Starts With Functions

PHP 8 or newer:
Use the str_starts_with function:

str_starts_with('http://www.google.com', 'http')
PHP 7 or older:
Use the substr function to return a part of a string.

substr( $string_n, 0, 4 ) === "http"
If you're trying to make sure it's not another protocol. I'd use http:// instead, since https would also match, and other things such as http-protocol.com.

substr( $string_n, 0, 7 ) === "http://"
And in general:

substr($string, 0, strlen($query)) === $query

1
0
168
Welcome to CodeXpress Forum Script - Download NL script Free


No comments. Be first to post a comment.

Reply to this article


Welcome, Guest: Join to reply login to reply!

♣ Post Statistic

1 guest(s) viewing this topic

Related Post

Php 8x Use Of Str Starts With Functions

♣ CodeXpress Statistic

Welcome, Guest: Join CodeXpress Login

17 Members, 135 topics and 9 posts
Date: Friday 01 July 2022 at 02:09 AM

Top 5 Contributors

People who started the most discussions on codexpress.

  1. 17
  2. 92
  3. 3
  4. 11
  5. 1

Sections

CodeXpress / General:
Politics, Business, Investment, Career, Autos, Counties, Properties, Agriculture, Health, Travel, Family, Culture, Religion, Food, Pets, Romance, Diaspora, Africa, International Forum, World List Directory, How To,
Science/Technology:
Programing, Webmasters, Computers, Phones, Art, Graphics & Video, Technology Market, CSS, Innovation, PHP 7x, Vanilla JS, Software Updates,

♣ Users Online: (2)

0 Members and 2 Guests online in last 5 minutes!


Sections:

Politics, Family, Travel, Culture, Agriculture, Technology Market, CSS, PHP 7x, Phones, Software Updates, Poetry, Fashion, Literature, Gossip, Forum Games,

CodeXpress - Copyright © 2019 - 2022 Marshall Unduemi. All rights reserved. See How To Advertise.
Disclaimer: Every CodeXpress member is solely responsible for anything that he/she posts or uploads on CodeXpress.