情定在深秋

文章 评论 浏览 27

情定在深秋 2025-02-20 20:29:49

一个选项是 pyjanitor ;它是围绕 pd.series.mask 的包装器,尽可能多地通过了dtypes的所有艰苦工作,也可以通过pandas:

# pip install pyjanitor
import pandas as pd
import janitor

(df
.assign(e = df.b + df.c + df.d)
# case_when is an alternation 
# of conditions and expected values
.case_when(df.a.eq('one') & df.b.lt(50), 0, # condition, value
           df.a.eq('two') & df.d.gt(50), 1, 
           2, # default
           column_name = 'f')
)

        a    b    c    d    e  f
0     one   45  234  123  402  0
1     one   34   66   45  145  0
2   three  556   12   55  623  2
3     two   32   44   98  174  1
4  eleven   97   99   17  213  2
5     two   33    3   22   58  2

One option is case_when from pyjanitor; it is a wrapper around pd.Series.mask and as much as possible passes all the hardwork of dtypes and the like to Pandas:

# pip install pyjanitor
import pandas as pd
import janitor

(df
.assign(e = df.b + df.c + df.d)
# case_when is an alternation 
# of conditions and expected values
.case_when(df.a.eq('one') & df.b.lt(50), 0, # condition, value
           df.a.eq('two') & df.d.gt(50), 1, 
           2, # default
           column_name = 'f')
)

        a    b    c    d    e  f
0     one   45  234  123  402  0
1     one   34   66   45  145  0
2   three  556   12   55  623  2
3     two   32   44   98  174  1
4  eleven   97   99   17  213  2
5     two   33    3   22   58  2

根据条件更新Pandas列

情定在深秋 2025-02-20 14:34:22

检查您的CDN-Strategry以匹配两个系统,或将其明确设置。

.env (shopware_cdn_strategy_default)或在文件 config/packages/shopware.yml (shopware.cdn.strategy)中

可以是 id> id> id ,<代码>文件名, yralth_filename 普通

我也不喜欢当前的行为。另请参阅: https://github.com/shopware/proposal/proposal/issues/50

Check your cdn-strategry to match on both systems, or set it explicit.

.env (SHOPWARE_CDN_STRATEGY_DEFAULT) or in file config/packages/shopware.yml (shopware.cdn.strategy)

This can be id, filename, physical_filename or plain.

I don't like the current behaviour, too. See also: https://github.com/shopware/proposal/issues/50

Shopware 6媒体文件路径来自数据库/MySQL

情定在深秋 2025-02-20 13:35:06

randchar 函数中有一个 bug的 oft

sub randChar(\f, \numGrp, \N) {
    my @things = [sprintf(f, $_) for 1..numGrp];     
    @things[[1..numGrp].roll(N)];
}   

@things 带有 1 indexes的数组索引 numgrp ,但是 @things 的最大索引是 numgrp -1 。因此,有时有一个(任何),而不是返回数组元素的一个(或更多)中的字符串。

您想要的是:

sub randChar(\f, \numGrp, \N) {
    my @things = [sprintf(f, $_) for 1..numGrp];     
    @things.roll(N); # call roll directly on @things
}   

There's a off by one bug in randChar function

sub randChar(\f, \numGrp, \N) {
    my @things = [sprintf(f, $_) for 1..numGrp];     
    @things[[1..numGrp].roll(N)];
}   

You're indexing the @things array with indexes from 1 to numGrp, but the biggest index of @things is numGrp - 1. So sometimes there's a (Any) instead of a string in one (or more) of the elements of the returned array.

What you want is this:

sub randChar(\f, \numGrp, \N) {
    my @things = [sprintf(f, $_) for 1..numGrp];     
    @things.roll(N); # call roll directly on @things
}   

raku nativeCall到Rust FFI Carray尺寸限制 - segfault

情定在深秋 2025-02-20 11:31:43

我不知道构建路径发生变化的原因。不幸的是,我无法复制您的经验。我创建了此DockerFile以替换:

FROM jaraco/multipy-tox

RUN pipx install httpie
RUN http GET https://files.pythonhosted.org/packages/a6/91/86a6eac449ddfae239e93ffc1918cf33fd9bab35c04d1e963b311e347a73/netifaces-0.11.0.tar.gz | tar xz
WORKDIR netifaces-0.11.0
RUN pip-run -q setuptools -- setup.py build > build1.txt
RUN pip-run -q setuptools -- setup.py build > build2.txt
CMD diff --unified build1.txt build2.txt

它会产生此输出:

 $ docker run -it @$(docker build -q .)
--- build1.txt  2022-09-05 14:54:42.639229009 +0000
+++ build2.txt  2022-09-05 14:54:43.869229009 +0000
@@ -1,16 +1,12 @@
 running build
 running build_ext
-checking for getifaddrs...found. 
-checking for getnameinfo...found. 
-checking for IPv6 socket IOCTLs...not found. 
-checking for optional header files...netash/ash.h netatalk/at.h netax25/ax25.h neteconet/ec.h netipx/ipx.h netpacket/packet.h netrose/rose.h linux/atm.h linux/llc.h linux/tipc.h linux/dn.h. 
-checking whether struct sockaddr has a length field...no. 
-checking which sockaddr_xxx structs are defined...at ax25 in in6 ipx un rose ash ec ll atmpvc atmsvc dn llc. 
-checking for routing socket support...no. 
-checking for sysctl(CTL_NET...) support...no. 
-checking for netlink support...yes. 
+checking for getifaddrs...found. (cached)
+checking for getnameinfo...found. (cached)
+checking for IPv6 socket IOCTLs...not found. (cached)
+checking for optional header files...netash/ash.h netatalk/at.h netax25/ax25.h neteconet/ec.h netipx/ipx.h netpacket/packet.h netrose/rose.h linux/atm.h linux/llc.h linux/tipc.h linux/dn.h. (cached)
+checking whether struct sockaddr has a length field...no. (cached)
+checking which sockaddr_xxx structs are defined...at ax25 in in6 ipx un rose ash ec ll atmpvc atmsvc dn llc. (cached)
+checking for routing socket support...no. (cached)
+checking for sysctl(CTL_NET...) support...no. (cached)
+checking for netlink support...yes. (cached)
 will use netlink to read routing table
-building 'netifaces' extension
-aarch64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DNETIFACES_VERSION=0.11.0 -DHAVE_GETIFADDRS=1 -DHAVE_GETNAMEINFO=1 -DHAVE_NETASH_ASH_H=1 -DHAVE_NETATALK_AT_H=1 -DHAVE_NETAX25_AX25_H=1 -DHAVE_NETECONET_EC_H=1 -DHAVE_NETIPX_IPX_H=1 -DHAVE_NETPACKET_PACKET_H=1 -DHAVE_NETROSE_ROSE_H=1 -DHAVE_LINUX_ATM_H=1 -DHAVE_LINUX_LLC_H=1 -DHAVE_LINUX_TIPC_H=1 -DHAVE_LINUX_DN_H=1 -DHAVE_SOCKADDR_AT=1 -DHAVE_SOCKADDR_AX25=1 -DHAVE_SOCKADDR_IN=1 -DHAVE_SOCKADDR_IN6=1 -DHAVE_SOCKADDR_IPX=1 -DHAVE_SOCKADDR_UN=1 -DHAVE_SOCKADDR_ROSE=1 -DHAVE_SOCKADDR_ASH=1 -DHAVE_SOCKADDR_EC=1 -DHAVE_SOCKADDR_LL=1 -DHAVE_SOCKADDR_ATMPVC=1 -DHAVE_SOCKADDR_ATMSVC=1 -DHAVE_SOCKADDR_DN=1 -DHAVE_SOCKADDR_LLC=1 -DHAVE_PF_NETLINK=1 -I/usr/include/python3.11 -c netifaces.c -o build/temp.linux-aarch64-cpython-311/netifaces.o
-creating build/lib.linux-aarch64-cpython-311
-aarch64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 build/temp.linux-aarch64-cpython-311/netifaces.o -L/usr/lib/aarch64-linux-gnu -o build/lib.linux-aarch64-cpython-311/netifaces.cpython-311-aarch64-linux-gnu.so

如果我在构建之间删除 build 文件,则没有差异。

输出路径由 setuptools 或可能是 distutils ,但我也观察到Netifaces具有a giant noreferrer“> giant setup.py file 影响输出目录的行为存在。

我建议的是:

  • (a)确定您要观察到的行为是网络属性所独有的还是使用扩展模块的其他(简单)软件包发生的。
  • (b)使用扩展模块的更简单的软件包,创建一组步骤,复制您观察到的行为。
  • (c)将断点或打印语句放在distutils/setuptools代码中的各个点上,以追踪行为并确定设置输出dir的位置以及如何更改。

I don't know the reason why the build path changes. Unfortunately, I'm unable to replicate your experience. I created this dockerfile in an attempt to replacate:

FROM jaraco/multipy-tox

RUN pipx install httpie
RUN http GET https://files.pythonhosted.org/packages/a6/91/86a6eac449ddfae239e93ffc1918cf33fd9bab35c04d1e963b311e347a73/netifaces-0.11.0.tar.gz | tar xz
WORKDIR netifaces-0.11.0
RUN pip-run -q setuptools -- setup.py build > build1.txt
RUN pip-run -q setuptools -- setup.py build > build2.txt
CMD diff --unified build1.txt build2.txt

It produces this output:

 $ docker run -it @$(docker build -q .)
--- build1.txt  2022-09-05 14:54:42.639229009 +0000
+++ build2.txt  2022-09-05 14:54:43.869229009 +0000
@@ -1,16 +1,12 @@
 running build
 running build_ext
-checking for getifaddrs...found. 
-checking for getnameinfo...found. 
-checking for IPv6 socket IOCTLs...not found. 
-checking for optional header files...netash/ash.h netatalk/at.h netax25/ax25.h neteconet/ec.h netipx/ipx.h netpacket/packet.h netrose/rose.h linux/atm.h linux/llc.h linux/tipc.h linux/dn.h. 
-checking whether struct sockaddr has a length field...no. 
-checking which sockaddr_xxx structs are defined...at ax25 in in6 ipx un rose ash ec ll atmpvc atmsvc dn llc. 
-checking for routing socket support...no. 
-checking for sysctl(CTL_NET...) support...no. 
-checking for netlink support...yes. 
+checking for getifaddrs...found. (cached)
+checking for getnameinfo...found. (cached)
+checking for IPv6 socket IOCTLs...not found. (cached)
+checking for optional header files...netash/ash.h netatalk/at.h netax25/ax25.h neteconet/ec.h netipx/ipx.h netpacket/packet.h netrose/rose.h linux/atm.h linux/llc.h linux/tipc.h linux/dn.h. (cached)
+checking whether struct sockaddr has a length field...no. (cached)
+checking which sockaddr_xxx structs are defined...at ax25 in in6 ipx un rose ash ec ll atmpvc atmsvc dn llc. (cached)
+checking for routing socket support...no. (cached)
+checking for sysctl(CTL_NET...) support...no. (cached)
+checking for netlink support...yes. (cached)
 will use netlink to read routing table
-building 'netifaces' extension
-aarch64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DNETIFACES_VERSION=0.11.0 -DHAVE_GETIFADDRS=1 -DHAVE_GETNAMEINFO=1 -DHAVE_NETASH_ASH_H=1 -DHAVE_NETATALK_AT_H=1 -DHAVE_NETAX25_AX25_H=1 -DHAVE_NETECONET_EC_H=1 -DHAVE_NETIPX_IPX_H=1 -DHAVE_NETPACKET_PACKET_H=1 -DHAVE_NETROSE_ROSE_H=1 -DHAVE_LINUX_ATM_H=1 -DHAVE_LINUX_LLC_H=1 -DHAVE_LINUX_TIPC_H=1 -DHAVE_LINUX_DN_H=1 -DHAVE_SOCKADDR_AT=1 -DHAVE_SOCKADDR_AX25=1 -DHAVE_SOCKADDR_IN=1 -DHAVE_SOCKADDR_IN6=1 -DHAVE_SOCKADDR_IPX=1 -DHAVE_SOCKADDR_UN=1 -DHAVE_SOCKADDR_ROSE=1 -DHAVE_SOCKADDR_ASH=1 -DHAVE_SOCKADDR_EC=1 -DHAVE_SOCKADDR_LL=1 -DHAVE_SOCKADDR_ATMPVC=1 -DHAVE_SOCKADDR_ATMSVC=1 -DHAVE_SOCKADDR_DN=1 -DHAVE_SOCKADDR_LLC=1 -DHAVE_PF_NETLINK=1 -I/usr/include/python3.11 -c netifaces.c -o build/temp.linux-aarch64-cpython-311/netifaces.o
-creating build/lib.linux-aarch64-cpython-311
-aarch64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 build/temp.linux-aarch64-cpython-311/netifaces.o -L/usr/lib/aarch64-linux-gnu -o build/lib.linux-aarch64-cpython-311/netifaces.cpython-311-aarch64-linux-gnu.so

If I remove the build file between builds, there's no diff.

The output path is determined by setuptools or possibly by distutils, but I also observe that netifaces has a giant setup.py file, so it's entirely possible the behavior affecting the output directory is there.

What I recommend is to:

  • (a) Determine if the behavior you're observing is unique to netifaces or happens to other (simpler) packages with an extension module.
  • (b) Using a simpler package with an extension module, create a set of steps that replicate the behavior you observe.
  • (c) Put breakpoints or print statements at various points in the distutils/setuptools code to trace the behavior and determine where the output dir is set and how it changes.

Python设置如何确定输出路径?

情定在深秋 2025-02-20 11:22:07

您不必编写与文件名相同的名称,您可以使用所需的别名名称,并直接在SRC中导入如下

   
import logolight from "../logo-light.png";

<img src={logolight} alt="logo" />

You don't have to write the same name as the filename You can use an alias name you want and import that directly in the src like below

   
import logolight from "../logo-light.png";

<img src={logolight} alt="logo" />

试图在React中导入图像

情定在深秋 2025-02-20 04:29:15

等待可接受的答案的版本

resolve: async name => {
    const page = await resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob("./Pages/**/*.vue"));
    page.default.layout ??= DefaultLayoutFile;
    return page;
  },

The async await version of the accepted answer

resolve: async name => {
    const page = await resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob("./Pages/**/*.vue"));
    page.default.layout ??= DefaultLayoutFile;
    return page;
  },

Laravel&#x2B中的默认持久布局;惯性Vite

情定在深秋 2025-02-20 02:30:34

函数中的本地变量具有自动存储持续时间,这通常意味着它们在函数的堆栈框架中分配。

如果您编译代码并查看生成的程序集,您将看到SP正在调整以为 car and model and wheels 获得空间初始化。您还将在 main 的末尾查看 std :: string :: string(),作为 car默认destructor剩下的一部分

实际上,我都不感到失望的是,没有一个编译器(GCC,Clang,ICC)发现您仅访问 a.Wheels ,而 A.Wheels 是4,而< Code> STD :: String destructor没有副作用,因为它们确实找出构造函数是NOP的,没有为空字符串分配任何内容。

我希望优化器能够完全优化 car ,并且仅离开 std :: cout&lt;&lt; 4;

Local variables in functions have automatic storage duration, which usually means they are allocated in the stack frame of the function.

If you compile your code and look at the generated assembly you will see the SP being adjusted to make space for the Car and model and wheels getting initialized. You will also see std::string::~string() being called at the end of main as part of what is left of the default destructor of Car.

I'm actually disappointed none of the compilers (gcc, clang, icc) figure out that you only access A.wheels and that A.wheels is 4 and that the std::string destructor has no side effect since they do figure out the constructor is a NOP and allocated nothing for an empty string.

I would hope the optimizer to optimize away the Car completely and only leave std::cout << 4;.

创建类时,没有分配内存,然后在类中保存的变量?

情定在深秋 2025-02-20 01:40:18

您可以将ARR对象作为字符串值传递为选项值中的字符串值,您可以找到一个工作示例在这里

import React, { useState } from "react";
import "antd/dist/antd.css";
import { Select } from "antd";

let arr = [
  { name: "trtr", ID: 5 },
  { name: "FGF", ID: 8 },
  { name: "adaf", ID: 4 },
  { name: "tyhrf", ID: 7 }
];

const App = () => {
  const [arrselected, setArrSelected] = useState({});

  const filterGroupRecord = (data) => {
    console.log(JSON.parse(data));
    setArrSelected(data);
  };

  return (
    <Select
      size="small"
      placeholder="Select..."
      allowClear
      showSearch
      onChange={(data) => filterGroupRecord(data)}
      value={arrselected}
      dropdownMatchSelectWidth={false}
      style={{ width: 250, marginLeft: 8, marginRight: 8 }}
      filterOption={(input, option) =>
        option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
      }
    >
      {arr &&
        arr.map(
          (dd) =>
            dd.name && (
              <Select.Option value={JSON.stringify(dd)}>
                {dd.name}
              </Select.Option>
            )
        )}
    </Select>
  );
};

export default App;


you can pass arr object as a string value in the option value you can find a working example here

import React, { useState } from "react";
import "antd/dist/antd.css";
import { Select } from "antd";

let arr = [
  { name: "trtr", ID: 5 },
  { name: "FGF", ID: 8 },
  { name: "adaf", ID: 4 },
  { name: "tyhrf", ID: 7 }
];

const App = () => {
  const [arrselected, setArrSelected] = useState({});

  const filterGroupRecord = (data) => {
    console.log(JSON.parse(data));
    setArrSelected(data);
  };

  return (
    <Select
      size="small"
      placeholder="Select..."
      allowClear
      showSearch
      onChange={(data) => filterGroupRecord(data)}
      value={arrselected}
      dropdownMatchSelectWidth={false}
      style={{ width: 250, marginLeft: 8, marginRight: 8 }}
      filterOption={(input, option) =>
        option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
      }
    >
      {arr &&
        arr.map(
          (dd) =>
            dd.name && (
              <Select.Option value={JSON.stringify(dd)}>
                {dd.name}
              </Select.Option>
            )
        )}
    </Select>
  );
};

export default App;


传递整个选定的对象数据on Change

情定在深秋 2025-02-19 20:01:14

如果您是指该程序终止的实际地址(或是否完全终止),则不。这只是著名停止问题的变体。事实证明,这没有一般解决方案。

最小值和最大地址正是在一个过程中分配的内存,但是根据确切的运行参数,该程序中可能会终止该程序的许多位置。而且它甚至可能没有到达他们中的任何一个。

If you mean the actual address that program terminates on (or whether it terminates at all), no. That is just a variation on the famous halting problem. And that has been proven to not have a general solution.

Minimum and maximum address are just what memory has been assigned to a process, but there could be many places in it that the program would terminate at, depending on the exact run parameters. And it might not even reach any of them.

是否可以在C中使用GetSystemInfo()获得程序启动和结束地址?

情定在深秋 2025-02-19 17:08:07

只需检查输入是否每次输入1时,当用户输入= 1时,只需打破循环即可。

string x;
while (true) {                                 // require a loop to input string and  end when user prompts                      
    cout << "Enter 1 to stop" << endl;
    cin >> x;
    if (x == "1"){
       break;
    }
    getline(cin, x);
    bookQ.push_back(x);
}
}    

simply check if input is 1 everytime the user enters somthing, and when it does = 1, simply break loop.

string x;
while (true) {                                 // require a loop to input string and  end when user prompts                      
    cout << "Enter 1 to stop" << endl;
    cin >> x;
    if (x == "1"){
       break;
    }
    getline(cin, x);
    bookQ.push_back(x);
}
}    

C&#x2B;&#x2B;字符串的循环

情定在深秋 2025-02-19 14:52:01

标准C ++库中的所有容器,包括向量,都具有可选的模板参数,实现自己的工作并不是很多工作:

class my_awesome_allocator {
};

std::vector<float, my_awesome_allocator> awesomely_allocated_vector;

您将不得不编写一些实现您的代码分配器,但这并不比您已经编写的代码更多。如果您不需要pre-c ++ 17支持,则只需要实现分配() dealLocate()方法,就是这样。

All containers in the standard C++ library, including vectors, have an optional template parameter that specifies the container's allocator, and it is not really a lot of work to implement your own one:

class my_awesome_allocator {
};

std::vector<float, my_awesome_allocator> awesomely_allocated_vector;

You will have to write a little bit of code that implements your allocator, but it wouldn't be much more code than you already written. If you don't need pre-C++17 support you only need to implement the allocate() and deallocate() methods, that's it.

使std ::矢量分配对齐记忆的现代方法

情定在深秋 2025-02-19 12:06:31

对于其他人:

使用C ++ 17这是间接的(非静态成员类型的自动扣除)。您需要使用模板和扣除指南来实现它:

template< class data_t>
struct MyType 
{
    data_t data;
    static constexpr auto data_size = sizeof(data_t);

    MyType( data_t && p_data ) : data(p_data) {}
};

template< class data_t>
MyType(data_t &&) -> MyType<std::remove_reference_t<data_t>>;

我不知道该怎么做,但是这款汽车成员确实需要将其纳入语言,而没有某些模式几乎是不可能的。

如果Lambda通过参考捕获了班级成员,则以上方案 工作。对于避免使用类型擦除功能的高度补偿类来说,这是一个有用的模式。我经常在嵌入式系统上做的事情。

https://godbolt.org/z/w-k9uk

您可以将语言误用在提交中使用位置new和offset_of引用不存在类的lambda,但这是可笑的,不需要。

For others:

Using C++17 this is indirectly (automatic deduction of non-static member type) possible. You need to use templates and deduction guides to make it happen:

template< class data_t>
struct MyType 
{
    data_t data;
    static constexpr auto data_size = sizeof(data_t);

    MyType( data_t && p_data ) : data(p_data) {}
};

template< class data_t>
MyType(data_t &&) -> MyType<std::remove_reference_t<data_t>>;

I don't know how but this auto members really need to make it into the language without them certain patterns are next to impossible.

The scenario above does not work if the lambda captures a member of class by reference. This is a useful pattern for, highly compensable classes that avoid the use of type erased functions. Something I regularly do on embedded systems.

https://godbolt.org/z/W-K9Uk

You can mangle the language into submission allowing a lambda to reference a member of a non-existent class using placement-new and offset_of but that is ludicrous and shouldn't be required.

C&#x2B; 11-声明非静态数据成员为&#x27; auto&#x27;

情定在深秋 2025-02-19 09:19:10

您可以将垂直方向用作中心和水平安排作为中心座,这将使列内范围内显示在中心中的视图。尽管您的用例不移动文本视图,而只是将进度指示器放在图像的中心和顶部,我建议将图像和进度指示器包装在盒子内,并给出内容对齐作为中心。对于

Box(contentAlignment = Alignment.Center) {
    CircularProgressIndicator()
    Image()
}

You can use verticalArrangement as Center and horizontalAlignment as CenterHorizontally, which will make views inside the column scope appear in the center. Although if your use case is not to move the text view and just put the progress indicator on the center and top of the image, I will recommend putting both the image and progress indicator wrap inside a Box and giving content alignment as the center. for e.g,

Box(contentAlignment = Alignment.Center) {
    CircularProgressIndicator()
    Image()
}

线圈:装载指示灯堆叠在图像顶部而不是更换图像?

情定在深秋 2025-02-18 13:56:56

您需要告诉编译器您的项目包含两个源文件:

gcc -o out main.c hello_world.c

另外,在您的级别上,我建议使用IDE(例如, eclipse cdt )专注于编程而不是构建。稍后,您将学习如何构建复杂的项目。但是现在只是学会编程。

You need to tell the compiler that your project contains two source files:

gcc -o out main.c hello_world.c

Also at your level, I would suggest to use an IDE (for example, Eclipse CDT) to focus on programming, not building. Later you will learn how to build complicated projects. But now simply learn to program.

C标题问题:#include and quot“未定义的参考”

情定在深秋 2025-02-18 10:41:59

getImagesize()仅用于图像文件。获得MIME类型的更通用功能是 Mime_content_type()

if(file_exists($file_name))
{
    $type = mime_content_type("$file_name");
    $fP = fOpen("$file_name", "rb");
    if($type and $fP)
    {
    header('last-modified: '.gmdate('D, d M Y H:i:s', filemtime($file_name)).' GMT');
    header('content-type: '.$type.');
    header('content-length: '.filesize($file_name).);
    fPassThru($fP);
    }
    exit;
}
else
{
    echo 'Bad ID!';
}

getImageSize() is just for image files. The more general function for getting MIME types is mime_content_type().

if(file_exists($file_name))
{
    $type = mime_content_type("$file_name");
    $fP = fOpen("$file_name", "rb");
    if($type and $fP)
    {
    header('last-modified: '.gmdate('D, d M Y H:i:s', filemtime($file_name)).' GMT');
    header('content-type: '.$type.');
    header('content-length: '.filesize($file_name).);
    fPassThru($fP);
    }
    exit;
}
else
{
    echo 'Bad ID!';
}

通过PHP脚本加载任何内容

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文